evenfurther / pathfinding

Pathfinding library for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFE: bidirectional search

cuviper opened this issue · comments

https://en.wikipedia.org/wiki/Bidirectional_search

It could be beneficial to some problems to search simultaneously from the start and end states to meet in the middle. The most general implementation would need to use separate successor and predecessor functions, but an undirected graph can use the same for both. I think at least BFS, Dijkstra, and A* (with separate heuristics) could support this.

I also wonder if there are any tricks to approximate bidirectional search with the existing API.

Hi Josh,

I'm not sure the current API can readily support a bidirectional search. In addition to the points you've already mentioned (the successors API not being inherently reversible in the general case, and the heuristic for A*/IDA* not being suited for the reverse direction), two other considerations come to mind:

  • When attempting this, you must maintain two sets of visited nodes to detect an intersection.
  • Bidirectional search might often be accomplished with two threads working in parallel, unlike unidirectional searches.

Incorporating advanced pathfinding techniques is something I'd love to see added to this crate. Bidirectional search and graph compression (with initial offline processing) are among those techniques. I would welcome such contributions, as I currently lack the resources to undertake them myself.

I'll leave the issue open as a feature request to keep track of this.