Skip to content

Commit

Permalink
Merge pull request #110 from napakalas/issue-#109
Browse files Browse the repository at this point in the history
Issue #109: Update Rendering for Multiple Containment
  • Loading branch information
dbrnz authored Jan 9, 2025
2 parents b081aaf + 09e9b00 commit 68fbfed
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mapmaker/routing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,9 @@ def get_node_feature(node_dict, neighbours, prev_features) -> Feature:
(temp_connectivity_graph := nx.Graph(connectivity_graph)).remove_nodes_from(centrelines)
subgraphs = [temp_connectivity_graph.subgraph(component) for component in nx.connected_components(temp_connectivity_graph)]
for subgraph in subgraphs:
if len([node for node, degree in subgraph.degree()
if degree == 1 and not any([connectivity_graph.has_edge(node, ct)] for ct in centrelines)]) == 0:
pseudo_terminals += list(subgraph.nodes)[0:1]
if len([node for node in subgraph.nodes if connectivity_graph.degree[node] == 1]) > 0:
break
pseudo_terminals += list(subgraph.nodes)[0:1]

terminal_graphs: dict[tuple, nx.Graph] = {}
visited = set()
Expand Down Expand Up @@ -1222,9 +1222,10 @@ def add_paths_to_neighbours(node, node_dict):
neighbours.update(downstream)
elif (neighbour_dict['type'] == 'feature'
and len(neighbour_dict.get('used', set())) == 0
and len(children:=neighbour_dict.get('contains', set()))) > 0:
if len(set(children) - set(visited)) == 0:
neighbours.remove(neighbour)
and len(children:=neighbour_dict.get('contains', set())) > 0):
# Replace the neighbour by it's children if the node is a downstream
neighbours.update(set(children) - set(visited))
neighbours.remove(neighbour)
# Connect to each neighbour of interest, noting those that will
# then need connecting
neighbours_neighbours = []
Expand Down

0 comments on commit 68fbfed

Please sign in to comment.