Skip to content

Enforce route restrictions using subgraph - #54

Closed
philipocalito wants to merge 2 commits into
genthalili:mainfrom
philipocalito:main
Closed

Enforce route restrictions using subgraph#54
philipocalito wants to merge 2 commits into
genthalili:mainfrom
philipocalito:main

Conversation

@philipocalito

Copy link
Copy Markdown

This pull request refactors how passage restrictions are handled when calculating the shortest path in the Marnet class. Instead of using custom weight functions to avoid restricted passages, it now leverages a filtered subgraph that excludes restricted edges. It raises a warning when no path exists due to restrictions. Additionally, test code has been updated to demonstrate passage closure scenarios.

Refactoring of passage restriction handling:

  • Replaced the custom weight functions (custom_weight and __custom_w) with a subgraph filter using nx.subgraph_view to exclude edges with restricted passages in shortest_path, simplifying the logic for handling restrictions. [1] [2] [3].

  • Given that the shortest distance is calculated on a subgraph view, the original graph is left unchanged.

Error handling improvements:

  • Added warnings when no path is found due to passage restrictions, returning None instead of raising an exception in shortest_path. This respects the current architecture in searoute.py.

Testing enhancements:

  • Updated test.py to include a test case for routing with closed passages, demonstrating the effect of passage restrictions on route calculation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant