Johnson’s Algorithm
Learn how Johnson’s algorithm uses single-source shortest-paths algorithms for computing all-pairs shortest-paths.
When tasked with finding the shortest paths between all pairs of vertices, calculating the shortest paths between them seems easy enough. In the presence of negative edge weights, our first instinct is to call the Bellman-Ford algorithm from each vertex.
This would certainly guarantee the detection of negative-weight cycles in the digraph. On the other hand, it would take a whopping time
in the
Get hands-on with 1400+ tech skills courses.