AllPairsShortestPath[g]
gives a matrix, where the entry is the length of a shortest path in g between vertices
and
.
AllPairsShortestPath[g,Parent]
returns a three-dimensional matrix with dimensions 2*V[g]*V[g], in which the entry is the length of a shortest path from
to
and the
entry is the predecessor of
in a shortest path from
to
.


AllPairsShortestPath
AllPairsShortestPath[g]
gives a matrix, where the entry is the length of a shortest path in g between vertices
and
.
AllPairsShortestPath[g,Parent]
returns a three-dimensional matrix with dimensions 2*V[g]*V[g], in which the entry is the length of a shortest path from
to
and the
entry is the predecessor of
in a shortest path from
to
.
Details and Options
- AllPairsShortestPath functionality is now available in the built-in Wolfram Language function GraphDistanceMatrix.
- To use AllPairsShortestPath, you first need to load the Combinatorica Package using Needs["Combinatorica`"].
Examples
Basic Examples (2)
AllPairsShortestPath has been superseded by GraphDistanceMatrix:
Tech Notes
Related Guides
-
▪
- Graph Algorithms ▪
- Graphs & Networks ▪
- Graph Visualization ▪
- Computation on Graphs ▪
- Graph Construction & Representation ▪
- Graphs and Matrices ▪
- Graph Properties & Measurements ▪
- Graph Operations and Modifications ▪
- Statistical Analysis ▪
- Social Network Analysis ▪
- Graph Properties ▪
- Mathematical Data Formats ▪
- Discrete Mathematics
Text
Wolfram Research (2012), AllPairsShortestPath, Wolfram Language function, https://reference.wolfram.com/language/Combinatorica/ref/AllPairsShortestPath.html.
CMS
Wolfram Language. 2012. "AllPairsShortestPath." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/Combinatorica/ref/AllPairsShortestPath.html.
APA
Wolfram Language. (2012). AllPairsShortestPath. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/Combinatorica/ref/AllPairsShortestPath.html
BibTeX
@misc{reference.wolfram_2025_allpairsshortestpath, author="Wolfram Research", title="{AllPairsShortestPath}", year="2012", howpublished="\url{https://reference.wolfram.com/language/Combinatorica/ref/AllPairsShortestPath.html}", note=[Accessed: 14-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_allpairsshortestpath, organization={Wolfram Research}, title={AllPairsShortestPath}, year={2012}, url={https://reference.wolfram.com/language/Combinatorica/ref/AllPairsShortestPath.html}, note=[Accessed: 14-August-2025]}