Alex Rivera | Logout

Dijkstra vs. Floyd-Warshall: Finding optimal route on all node pairs

Asked 2010-11-18T07:10:57.350
37

I am reading up on Dijkstra's algorithm and the Floyd-Warshall algorithm. I understand that Dijkstra's finds the optimal route from one node to all other nodes and Floyd-Warshall finds the optimal route for all node pairings.

My question is would Dijkstra's algorithm be more efficient than Floyd's if I run it on every single node in order to find the optimal route between all pairings.

Dijkstra's runtime is O(E + VlogV) where Floyd's is O(V3). If Dijkstra's fails, what would its runtime be in this case? Thanks!

Edit
Report

1 Answer

12

The complexity for running Dijkstra on all nodes will be O(EV + V2logV). This complexity is lower than O(V3) iff E < V2.

answered 2010-11-18T07:27:21.577

Your Answer