ShortestPath[g,start,end]
finds a shortest path between vertices start and end in graph g.
ShortestPath
ShortestPath[g,start,end]
finds a shortest path between vertices start and end in graph g.
更多信息和选项
- ShortestPath functionality is now available in the built-in Wolfram Language function FindShortestPath.
- To use ShortestPath, 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 using 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.
范例
基本范例 (2)
Needs["Combinatorica`"]g = FromAdjacencyMatrix[{{0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0}}];ShowGraph[g]ShortestPath[g, 1, 2]ShortestPath has been superseded by FindShortestPath:
g = AdjacencyGraph[{{0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0}}]FindShortestPath[g, 1, 2]相关指南
-
▪
- Combinatorica Package ▪
- 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
文本
Wolfram Research (2012),ShortestPath,Wolfram 语言函数,https://reference.wolfram.com/language/Combinatorica/ref/ShortestPath.html.
CMS
Wolfram 语言. 2012. "ShortestPath." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/Combinatorica/ref/ShortestPath.html.
APA
Wolfram 语言. (2012). ShortestPath. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/Combinatorica/ref/ShortestPath.html 年
BibTeX
@misc{reference.wolfram_2026_shortestpath, author="Wolfram Research", title="{ShortestPath}", year="2012", howpublished="\url{https://reference.wolfram.com/language/Combinatorica/ref/ShortestPath.html}", note=[Accessed: 08-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_shortestpath, organization={Wolfram Research}, title={ShortestPath}, year={2012}, url={https://reference.wolfram.com/language/Combinatorica/ref/ShortestPath.html}, note=[Accessed: 08-August-2026]}