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
if neighbor in self.H: (neighbor,) = neighbors
self._del_edge(neighbor, site) if neighbor in self.H:
if self._out_degree(neighbor) > 1: # neighbor is in the fundamental domain
neighbor = False edge = (neighbor, site)
else:
self._del_edge(*to_fd(neighbor, site))
if self._out_degree(to_fd(neighbor)) > 1:
neighbor = False
else: else:
neighbor = False edge = self.symmetry.to_fd(neighbor, site)
neighbor = self.symmetry.to_fd(neighbor)
self._del_edge(*edge)
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