Why it matters
Better than Floyd-Warshall for sparse graphs. Understanding shapes algorithm choice.
Advertisement
The architecture
Add virtual source with 0-edges to all.
Bellman-Ford: compute h.
Reweight: w' = w + h(u) - h(v).
Dijkstra from each vertex.
Advertisement
How it works end to end
Bellman-Ford detects negative cycles.
Reweighting preserves shortest paths.
Dijkstra runs on non-negative weights.