Overview
Floyd-Warshall improves a distance table by checking whether each node is a useful intermediate stop.
Finds shortest paths between every pair of nodes.
Compact metadata for implementation and discovery.
Floyd-Warshall improves a distance table by checking whether each node is a useful intermediate stop.
Quick facts
Runtime and memory behavior at a glance.
Best
O(V^3)
Average
O(V^3)
Worst
O(V^3)
Space
O(V^2)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])Checks whether routing through node k improves the best known path from i to j.
Show a distance matrix improving as each intermediate node is considered.
Floyd-Warshall operates in O(V^3) time and O(V^2) space within the Dynamic Programming family. Key governing relation: dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]). Often compared with Bellman-Ford and Dijkstra's Algorithm.
What each reference supports for this entry.
Textbook reference for the algorithmic family and analysis of Floyd-Warshall.
Good next jumps from the relationship graph, ranked for useful discovery.
Pathfinding · Extended
Floyd-Warshall is preferred for dense all-pairs shortest paths, while Johnson's Algorithm is better for sparse graphs.
Compare with thisBoth use dynamic programming over graph structure.
Floyd-Warshall is preferred for dense all-pairs shortest paths, while Johnson's Algorithm is better for sparse graphs.