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 from nodes[i] to nodes[j] (inf if unreachable, 0 on the diagonal); nodes is graph order. Negative weights are fine; a negative cycle raises NegativeCycleError naming the cycle. O(n³) time, O(n²) memory.