Enforce route restrictions using subgraph - #54
Closed
philipocalito wants to merge 2 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how passage restrictions are handled when calculating the shortest path in the
Marnetclass. 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_weightand__custom_w) with a subgraph filter usingnx.subgraph_viewto exclude edges with restricted passages inshortest_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:
Noneinstead of raising an exception inshortest_path. This respects the current architecture insearoute.py.Testing enhancements:
test.pyto include a test case for routing with closed passages, demonstrating the effect of passage restrictions on route calculation.