concept

Johnson's Algorithm

Johnson's Algorithm is a graph theory algorithm used to find the shortest paths between all pairs of vertices in a weighted, directed graph that may contain negative edge weights, but no negative cycles. It works by first reweighting the graph using the Bellman-Ford algorithm to eliminate negative weights, then applying Dijkstra's algorithm to each vertex. This approach efficiently computes all-pairs shortest paths in graphs where Dijkstra's algorithm alone cannot handle negative weights.

Also known as: Johnson Algorithm, Johnson's, Johnson, All-Pairs Shortest Path Algorithm, Johnson's Shortest Path
🧊Why learn Johnson's Algorithm?

Developers should learn Johnson's Algorithm when working on applications involving network routing, logistics optimization, or any scenario requiring shortest path calculations in graphs with potentially negative edge weights, such as in financial arbitrage or certain game theory problems. It is particularly useful in competitive programming, algorithm design, and systems where graph-based data structures model real-world constraints with varied cost metrics.

Compare Johnson's Algorithm

Learning Resources

Related Tools

Alternatives to Johnson's Algorithm