Skip to content

Commit

Permalink
Test opposite and unindent in shortest path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Feb 20, 2024
1 parent ff8cbc4 commit beb0b76
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions swmmanywhere/graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,15 @@ def __call__(self, G: nx.Graph,
alt_dist = dist + edge_data['weight']
# If the alternative distance is shorter

if alt_dist < shortest_paths[neighbor]:
# Update the shortest path length
shortest_paths[neighbor] = alt_dist
# Update the path
paths[neighbor] = paths[node] + [neighbor]
# Push the neighbor to the heap
heappush(heap, (alt_dist, neighbor))
if alt_dist >= shortest_paths[neighbor]:
continue

# Update the shortest path length
shortest_paths[neighbor] = alt_dist
# Update the path
paths[neighbor] = paths[node] + [neighbor]
# Push the neighbor to the heap
heappush(heap, (alt_dist, neighbor))

edges_to_keep = set()
for path in paths.values():
Expand Down

0 comments on commit beb0b76

Please sign in to comment.