aryagraph.algorithms.paths.floyd_warshall#
- aryagraph.algorithms.paths.floyd_warshall(g: Graph, weight: str | Callable[[Hashable, Hashable, dict], float] | None = 'weight') tuple[ndarray, list[Hashable]][source]#
All-pairs distances by Floyd–Warshall, vectorised over numpy.
Returns
(D, nodes):D[i, j]is the distance fromnodes[i]tonodes[j](infif unreachable, 0 on the diagonal); nodes is graph order. Negative weights are fine; a negative cycle raisesNegativeCycleErrornaming the cycle. O(n³) time, O(n²) memory.