Back
johnson (clj)
(source)function
(johnson g)
Finds all-pairs shortest paths using Bellman-Ford to remove any negative edges before
using Dijkstra's algorithm to find the shortest paths from each vertex to every other.
This algorithm is efficient for sparse graphs.
If the graph is unweighted, a default weight of 1 will be used. Note that it is more efficient
to use breadth-first spans for a graph with a uniform edge weight rather than Dijkstra's algorithm.
Most callers should use shortest-paths and allow the most efficient implementation be selected
for the graph.