Verified Commit 47d7302e authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

clarify and streamline the logic of eradicate dangling

parent 0526bda4
Pipeline #38260 passed with stages
in 13 minutes and 8 seconds
...@@ -886,32 +886,32 @@ class Builder: ...@@ -886,32 +886,32 @@ class Builder:
Sites are considered as dangling when less than two hoppings Sites are considered as dangling when less than two hoppings
lead to them. lead to them.
""" """
to_fd = self.symmetry.to_fd
sites = list(site for site in self.H sites = list(site for site in self.H
if self._out_degree(site) < 2) if self._out_degree(site) < 2)
for site in sites: for site in sites:
# We could have deleted the site already if there was e.g. an
# isolated hopping.
if site not in self.H: if site not in self.H:
continue continue
while site:
if site not in self.H: while self._out_degree(site) < 2:
site = to_fd(site)
neighbors = tuple(self._out_neighbors(site)) neighbors = tuple(self._out_neighbors(site))
if neighbors: if not neighbors:
assert len(neighbors) == 1 del self.H[site]
neighbor = neighbors[0] break
# test if neighbor in fundamental domain
(neighbor,) = neighbors
if neighbor in self.H: if neighbor in self.H:
self._del_edge(neighbor, site) # neighbor is in the fundamental domain
if self._out_degree(neighbor) > 1: edge = (neighbor, site)
neighbor = False
else: else:
self._del_edge(*to_fd(neighbor, site)) edge = self.symmetry.to_fd(neighbor, site)
if self._out_degree(to_fd(neighbor)) > 1: neighbor = self.symmetry.to_fd(neighbor)
neighbor = False self._del_edge(*edge)
neighbor = False
del self.H[site] del self.H[site]
# Neighbor could become dangling now.
site = neighbor site = neighbor
def __iter__(self): def __iter__(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment