GraphTheory
AllShortestPaths
find all shortest paths between two vertices
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
AllShortestPaths(G, u, v)
G
-
graph
u, v
vertices of the graph
output = one of iterator, list, or set
Specifies what is returned from AllShortestPaths. The default is iterator.
AllShortestPaths(G, u, v) returns all shortest paths from u to v in a graph G.
The default output is an Iterator.
with⁡GraphTheory:
C6≔CycleGraph⁡6
C6≔Graph 1: an undirected graph with 6 vertices and 6 edges
iter≔AllShortestPaths⁡C6,1,4
iter≔Shortest Path Iterator
forpathiniterdoprint⁡pathenddo
1,2,3,4
1,6,5,4
C23≔CompleteGraph⁡2,3
C23≔Graph 2: an undirected graph with 5 vertices and 6 edges
AllShortestPaths⁡C23,1,2,output=set
1,3,2,1,4,2,1,5,2
The GraphTheory[AllShortestPaths] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
BellmanFordAlgorithm
DijkstrasAlgorithm
Distance
IsReachable
Reachable
Download Help Document