How to solve APSP problem using SSSP solution for unweighted graph? + Time Complexity
Running BFS from each vertex. O(V^3) if E = O(V^2)
How to solve APSP problem using SSSP solution for weighted graph? + Time Complexity (2 ways)
Running Bellman Ford V times, once from each vertex
- O(V^4) if E = O(V^2)
Running original/modified Dijkstra’s V times, once from each vertex
- O(V^3 logV) if E = O(V^2)
What DS does Floyd Warshall use?
2D array to store distances
Main way Floyd Warshall is used
As a preprocessing step, so that future queries about shortest paths can be answered in O(1) time
4 Variants of Floyd Warshall