Adding cutoff to A* to allow early termination #7026
anders-rydbirk
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
I think a cutoff parameter is reasonable (though maybe tricky to get right) for the astar algorithm here. |
Beta Was this translation helpful? Give feedback.
4 replies
-
PR with implementation: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
We currently have a case where we build a graph with approx. 50_000 nodes and 230_000 edges. We do online search in the graph using
nx.algorithms.shortest_paths.astar_path
where we:nx.subgraph_view
However, we experience that sometimes the target cannot be reached from the source during step 1, while the source is connected to fairly large subset of the graph. I.e. we end up exhausting most of the graph before defaulting to step 2. This can easily end up taking 2,5-3s of processing which exhausts our API.
Our idea was to introduce a cutoff to terminate the search early, similar to what already exists for the dijkstra implementations. For us, it would probably be set to
X * heuristic(source, target)
.SuggestionIgnore this below, it's incorrect, but we keep it for context in the discussionUnless there's a big push against it, I wouldn't mind contributing this change as well.
Beta Was this translation helpful? Give feedback.
All reactions