aryagraph.algorithms.paths.all_pairs_shortest_path_length#
- aryagraph.algorithms.paths.all_pairs_shortest_path_length(g: Graph, weight: str | Callable[[Hashable, Hashable, dict], float] | None = None) dict[Hashable, NodeMap][source]#
Distances between every pair of mutually reachable nodes, as
{u: NodeMap{v: d}}.BFS when unweighted, Dijkstra for non-negative weights, and Johnson’s reweighting (one Bellman–Ford + n Dijkstra runs) when some weight is negative. Unreachable pairs are absent. Raises
NegativeCycleErrorif the graph has a negative cycle.