graphgraph-theorydijkstraa-starpgrouting

Pgr_astar slower than pgr_dijkstra, Pgrouting


So i'm using pgrouting to compute shortest path on transit network, The cost of my graph is time, but the graph isn't "time dependent" - which means my arcs are available at every hour everyday, the cost is not the distance between station but the time it take to move from one point to another. I figured by doing the computation that pgr_astar (and even pgr_bdAstar) is slower than pgr_dijkstra. I thought it might be a factor problem for the heuristic.

My questions is :

Is it possible for a graph this simple with at least 1 millions of edge that pgr_astar and pgr_bdAstar are slower than pgr_dijkstra ? I tried pgr_astar on a lot of couple of stations very far away with all the possible heuristic comparing to pgr_dijkstra and every time pgr_dijkstra is faster (time_computation) but the result of the shortest path is the same. My graph are edge of transit line (Metro, Train, Tramway, Bus),


Solution

  • Why do you expect Dijkstra to be slower than A*?

    If you provide A* with a very good heuristic then it will be faster because it performs a guided search for just one path ( Dijsktra finds the cheapest path from the start to every other vertex. ) If your heuristic is poor, then A* will check a lot of paths that lead nowhere.

    And of course, the speed depends on the quality of the implementations. perhaps your library implementers did a better job with Dijsktra?

    The good thing is that you have measured the performance of both algorithms and found which is better for your application. So, I recommend using the one you found gave the better results and move on to the next problem!