Why it matters

Floyd-Warshall is simple and general. Great for small dense graphs.

Advertisement

The architecture

dp[i][j] using k as intermediate.

Iterate k, i, j.

O(V^3) time.

Floyd-Warshall deep divedp[i][j] via kintermediate vertexIteratek, i, jResultall-pairs shortestFloyd 1962 + Warshall 1962; V^3 time; simple and general
Floyd-Warshall deep dive.
Advertisement

How it works end to end

DP over intermediate vertices.

O(V^3) time.

Handles negative weights.