remove dead ends

pull/1803/head
Lex Neva 2023-02-08 15:39:50 -05:00
rodzic f2344375df
commit 3515ca399b
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -139,8 +139,19 @@ class Tile:
if shape.contains(line_string):
graph.add_edge(line[0], line[1])
self._remove_dead_ends(graph)
return graph
def _remove_dead_ends(self, graph):
while True:
nodes_with_degree_1 = [node for node, degree in graph.degree() if degree == 1]
if nodes_with_degree_1:
graph.remove_nodes_from(nodes_with_degree_1)
else:
return
def all_tile_paths():
return [os.path.join(guess_inkscape_config_path(), 'tiles'),