ShortestPathFunction[type,data]
represents a function that gives the shortest path from a source vertex s to target vertex t in a graph.


ShortestPathFunction
ShortestPathFunction[type,data]
represents a function that gives the shortest path from a source vertex s to target vertex t in a graph.
Details

- ShortestPathFunction[…] is generated by FindShortestPath.
- ShortestPathFunction[{s,All},…][t] gives the shortest path from s to t.
- ShortestPathFunction[{All,t},…][s] gives the shortest path from s to t.
- ShortestPathFunction[{All,All},…][s,t] gives the shortest path from s to t.
Examples
open all close allBasic Examples (1)
Scope (7)
ShortestPathFunction works with undirected graphs:
A ShortestPathFunction can give shortest paths from a fixed vertex:
ShortestPathFunction returns {} when no path exists:
Related Guides
History
Text
Wolfram Research (2010), ShortestPathFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ShortestPathFunction.html.
CMS
Wolfram Language. 2010. "ShortestPathFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ShortestPathFunction.html.
APA
Wolfram Language. (2010). ShortestPathFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ShortestPathFunction.html
BibTeX
@misc{reference.wolfram_2025_shortestpathfunction, author="Wolfram Research", title="{ShortestPathFunction}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/ShortestPathFunction.html}", note=[Accessed: 11-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_shortestpathfunction, organization={Wolfram Research}, title={ShortestPathFunction}, year={2010}, url={https://reference.wolfram.com/language/ref/ShortestPathFunction.html}, note=[Accessed: 11-August-2025]}