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.

FindShortestPath[{vw,},]

uses rules vw to specify the graph g.

Details and Options

Examples

open allclose all

Basic Examples  (1)

Find a shortest path between two individual vertices in a graph:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Highlight the path:

In[3]:=
Click for copyable input
Out[3]=

Scope  (9)

Options  (3)

Applications  (3)

Properties & Relations  (1)

See Also

FindPath  FindHamiltonianPath  FindShortestTour  ShortestPathFunction  GraphDistance  GraphDistanceMatrix  FindMaximumFlow

Introduced in 2010
(8.0)
| Updated in 2015
(10.3)