Floyd–Warshall

Computes shortest paths between all pairs via dynamic programming over intermediate nodes.

Method

dist[k][i][j] = min(dist[k-1][i][j], dist[k-1][i][k]+dist[k-1][k][j]).

Applications

Transit networks, social graphs, routing tables.

Advantages

Simple, O(V^3), elegant DP.

Limitations

O(V^3); too slow for huge sparse graphs.

Example

Road network: one run gives every city-to-city shortest distance.

Sources

Educational reference only, not professional advice.

All algorithms