3

I want to know the time-complexity of a bidirectional Dijkstra algorithm.

A normal Dijkstra using a Min-Heap has O(n log n + m). My guess would be that the Bidirectional stays same. However Wikipedia suggests that the improvement of Bidirectional Search in general can be expressed in O-Notation.

Is this possible to calculate for the bidirectional Dijkstra as well and how?

Denis Lukenich
  • 3,084
  • 1
  • 20
  • 38

1 Answers1

6

Basically the bidirectional approach cost twice the monodirectional processing of a half-sized graph . For brute-force exponential algorithms that's a huge gain (from O(mn) to O(2*(mn/2)).
For Djikstra, the worst case remains basically the same.

However, time complexity is maybe not the best metric to assess efficiency here.

In practical cases like finding a route on a road network, bidirectional approach is akin to growing a disc around each end and stop (nearly) as soon as both discs meet, while a single-direction approach would require to grow a disc from the start until you reach the end.

Intuitively, if R is the straight distance between start and end, the cost of a straigth search would be O(R2), while the bidirectional approach would be in O(2*(R/2)2), i.e. 2 times faster.

this paper covers the topic pretty well.

And at any rate, A* is basically the way to go unless you're exploring a search space where no efficient estimate heuristic is available.

kuroi neko
  • 8,479
  • 1
  • 19
  • 43
  • Great answer. I am mainly using it for Road - Networks where I indeed use A-Star or if I have the change to do some preprocessing: Contraction Hierarchies. – Denis Lukenich Nov 24 '15 at 09:57
  • I only used A* in computing challenges or video-game-ish code so far, and I found the birirectional approach much too bulky to implement. There are other ways to improve time efficiency, notably by adding a tie-breaker to the estimate distance heuristic (when moving on tiles where many equivalent paths are available) or, like the paper I refered to explains, adding carefully chosen helper waypoints or precomputing shortcuts. – kuroi neko Nov 24 '15 at 10:05