This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

ShortestPathFunction

ShortestPathFunction
represents a function that gives the shortest path from a source vertex s to target vertex t in a graph.
Obtain a function that gives shortest paths from vertex 4:
Use it to show the shortest paths to all vertices:
Obtain a function that gives shortest paths from vertex 4:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Use it to show the shortest paths to all vertices:
In[3]:=
Click for copyable input
Out[3]=
ShortestPathFunction works with undirected graphs:
Directed graphs:
Weighted graphs:
A ShortestPathFunction can give shortest paths from a fixed vertex:
To a fixed vertex:
Between any pair of vertices:
ShortestPathFunction returns when no path exists:
New in 8