diff options
Diffstat (limited to 'lib/tiles.py')
| -rw-r--r-- | lib/tiles.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/tiles.py b/lib/tiles.py index 9986183b..7f46a5aa 100644 --- a/lib/tiles.py +++ b/lib/tiles.py @@ -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'), |
