ShortestPathSpanningTree[g,v]
constructs a shortest-path spanning tree rooted at v, so that a shortest path in graph g from v to any other vertex is a path in the tree.
ShortestPathSpanningTree
ShortestPathSpanningTree[g,v]
constructs a shortest-path spanning tree rooted at v, so that a shortest path in graph g from v to any other vertex is a path in the tree.
Details and Options
- ShortestPathSpanningTree functionality is now available in the built-in Wolfram Language function FindSpanningTree.
- To use ShortestPathSpanningTree, you first need to load the Combinatorica Package using Needs["Combinatorica`"].
- An option Algorithm that takes on the values Automatic, Dijkstra, or BellmanFord is provided. This allows a choice between Dijkstra's algorithm and the Bellman–Ford algorithm.
- The default is Algorithm->Automatic. In this case, depending on whether edges have negative weights and depending on the density of the graph, the algorithm chooses between BellmanFord and Dijkstra.
Examples
Basic Examples (2)
Needs["Combinatorica`"]g = FromAdjacencyMatrix[{{0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0}}];ShowGraph[g]ShortestPathSpanningTree[g, 1];ShowGraph[%]ShortestPathSpanningTree has been superseded by FindSpanningTree:
g = AdjacencyGraph[{{0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0}}]FindSpanningTree[g, 1]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), ShortestPathSpanningTree, Wolfram Language function, https://reference.wolfram.com/language/Combinatorica/ref/ShortestPathSpanningTree.html.
CMS
Wolfram Language. 2012. "ShortestPathSpanningTree." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/Combinatorica/ref/ShortestPathSpanningTree.html.
APA
Wolfram Language. (2012). ShortestPathSpanningTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/Combinatorica/ref/ShortestPathSpanningTree.html
BibTeX
@misc{reference.wolfram_2026_shortestpathspanningtree, author="Wolfram Research", title="{ShortestPathSpanningTree}", year="2012", howpublished="\url{https://reference.wolfram.com/language/Combinatorica/ref/ShortestPathSpanningTree.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_shortestpathspanningtree, organization={Wolfram Research}, title={ShortestPathSpanningTree}, year={2012}, url={https://reference.wolfram.com/language/Combinatorica/ref/ShortestPathSpanningTree.html}, note=[Accessed: 15-June-2026]}