GraphDistanceMatrix
All-pairs shortest-path distances of a Graph, as a matrix.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
GraphDistanceMatrix✓GraphDistanceMatrix(g)row/column order follows VertexList(g); entry (i, j) is GraphDistance(g, v_i, v_j).Typed signatures
| Type | Package | Applies |
|---|---|---|
(value) -> list<list<real | signed_infinity>> | combinatorics | always |
Details
- Respects edge direction, same as GraphDistance itself -- row i is the distances FROM vertex i.
- An unreachable pair reads PositiveInfinity, matching GraphDistance on a disconnected graph.
- Weighted (g carries EdgeWeight): every entry is GraphDistance's own weighted (Dijkstra, summed-weight) reading, not an edge count; a negative weight leaves the WHOLE matrix unevaluated, same as GraphDistance itself.
Examples
About
| Examples | 3 |
|---|---|
| Checked against | Wolfram Language 3 agree |
| Crosswalk | Wolfram Language |
See also: GraphDistance, FindShortestPath, WeightedAdjacencyMatrix, VertexEccentricity