Main Purposes:
- Dijkstra’s Algorithm is one example of a single-source shortest or SSSP algorithm, i.e., given a source vertex it finds shortest path from source to all other vertices.
- Floyd Warshall Algorithm is an example of all-pairs shortest path algorithm, meaning it computes the shortest path between all pair of nodes.
Time Complexities :
- Time Complexity of Dijkstra’s Algorithm: O(E log V)
- Time Complexity of Floyd Warshall: O(V3)
Other Points:
- We can use Dijskstra’s shortest path algorithm for finding all pair shortest paths by running it for every vertex. But time complexity of this would be O(VE Log V) which can go (V3 Log V) in worst case.
- Another important differentiating factor between the algorithms is their working towards distributed systems. Unlike Dijkstra’s algorithm, Floyd Warshall can be implemented in a distributed system, making it suitable for data structures such as Graph of Graphs (Used in Maps).
- Lastly Floyd Warshall works for negative edge but no negative cycle, whereas Dijkstra’s algorithm don’t work for negative edges.
This article is contributed by Vineet Joshi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- Find whether it is possible to finish all tasks or not from given dependencies
- Find the ordering of tasks from given dependencies
- Graph Types and Applications
- De Bruijn sequence | Set 1
- Minimum time to return array to its original state after given modifications
- Right sibling of each node in a tree given as array of edges
- Find maximum path length in a binary matrix
- Maximum number of edges among all connected components of an undirected graph
- Number of Walks from source to destination
- Check if a given tree graph is linear or not
- All vertex pairs connected with exactly k edges in a graph
- Edge Coloring of a Graph
- Finding the probability of a state at a given time in a Markov chain | Set 2
- Find the probability of a state at a given time in a Markov chain | Set 1



