|
SOLUTIONS
|
BUILT-IN MATHEMATICA SYMBOL
FindShortestPath
FindShortestPath[g, s, t]
finds the shortest path from source vertex s to target vertex t in the graph g.
FindShortestPath[g, s, All]
generates a ShortestPathFunction[...] that can be applied repeatedly to different t.
FindShortestPath[g, All, t]
generates a ShortestPathFunction[...] that can be applied repeatedly to different s.
FindShortestPath[g, All, All]
generates a ShortestPathFunction[...] that can be applied to different s and t.
Details and OptionsDetails and Options
- FindShortestPath[g, s, t] gives a path from s to t.
- FindShortestPath[g, s] is equivalent to FindShortestPath[g, s, All].
- FindShortestPath[g] is equivalent to FindShortestPath[g, All, All].
- For an unweighted graph, edge length is assumed to be 1.
- For a weighted graph, edge length is taken to be the weight.
- A Method option can also be given. Possible Method settings include:
-
"BellmanFord" supports positive and negative weights "Dijkstra" supports positive weights
New in 8
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »


