GraphDistance
The length of a shortest u to v path, respecting edge direction.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
GraphDistance✓GraphDistance(g, u, v)the number of edges on a shortest path, or if is unreachable from .Typed signatures
| Type | Package | Applies |
|---|---|---|
(value, any, any) -> value | combinatorics | always |
Details
- Weighted (g carries EdgeWeight -> {…}): the SUM of edge weights along the cheapest path (Dijkstra), not an edge count — read numerically, so an exact weight (a fraction, say) comes back as a float, not kept exact. Requires every weight non-negative; a negative one leaves the call unevaluated (see FindShortestPath's own note).
Examples
1 more kept as data, checked against the oraclesAbout
| Examples | 4 |
|---|---|
| Checked against | Wolfram Language 3 agree |
| Crosswalk | Wolfram Language |
See also: FindShortestPath, GraphDistanceMatrix, WeightedAdjacencyMatrix, ConnectedComponents