Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bidirectional A* (A-star) Search

I'm implementing a bidirectional A* search (bidirectional as in the search is performed from both the origin and destination simultaneously, and when these two searches meet, I'll have my shortest path - at least with a bit of extra logic thrown in).

Does anyone have any experience with taking a unidirectional A* and bidirectionalising(!) it - what sort of performance gain can I expect? I'd reckoned on it more-or-less halving the search time, at a minimum - but may I see bigger gains that this? I'm using the algorithm to determine shortest routes on a road network - if that's in any way relevant (I've read about MS's "Reach" algorithm, but want to take baby-steps towards this rather than jumping straight in).

like image 293
Will A Avatar asked Sep 04 '10 09:09

Will A


People also ask

Would A bidirectional A* search be A good idea?

Bidirectional search#It's a good idea that will help in some situations. The idea behind bidirectional searches is that searching results in a “tree” that fans out over the map. A big tree is much worse than two small trees, so it's better to have two small search trees.

WHAT IS A* search technique?

A* (pronounced "A-star") is a graph traversal and path search algorithm, which is used in many fields of computer science due to its completeness, optimality, and optimal efficiency. One major practical drawback is its. space complexity, as it stores all generated nodes in memory.

How do I find my bidirectional search?

Bidirectional search is a graph search algorithm that finds a shortest path from an initial vertex to a goal vertex in a directed graph. It runs two simultaneous searches: one forward from the initial state, and one backward from the goal, stopping when the two meet.

Is A * The best pathfinding algorithm?

A* is the most popular choice for pathfinding, because it's fairly flexible and can be used in a wide range of contexts. A* is like Dijkstra's Algorithm in that it can be used to find a shortest path. A* is like Greedy Best-First-Search in that it can use a heuristic to guide itself.


3 Answers

In the best possible case it'd run in O(b^(n/2)) instead of O(b^n), but that's only if you're lucky :)

(where b is your branching factor and n is the number of nodes a unidirectional A* would consider)

It all depends on how easily the two searches meet, if they find each other at a good halfway point early in the search you've done away with a lot of search time, but if they branch into wildly different directions you may end up with something slower than simple A* (because of all the extra bookkeeping)

like image 167
Michael Clerx Avatar answered Oct 15 '22 09:10

Michael Clerx


You may want to try https://github.com/sroycode/tway there is a benchmarking script that compares this with standard astar ( for NY city roads data it seems to give a 30% time benefit )

like image 27
SRC Avatar answered Oct 15 '22 09:10

SRC


You may consider clustering as much more efficient booster. Also see this article

like image 1
Andrii Andriichuk Avatar answered Oct 15 '22 08:10

Andrii Andriichuk