GraphTheory
AllSimplePaths
find all simple paths between two vertices
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
AllSimplePaths(G, u, v)
G
-
graph
u, v
vertices of the graph
maxweight = extended_numeric
Specifies a maximum weight for the paths returned. Paths exceeding this will be omitted from the iteration. The default is infinity.
output = one of iterator, list, or set
Specifies what is returned from AllSimplePaths. The default is iterator.
AllSimplePaths(G, u, v) returns all simple paths from u to v in a graph G.
The default output is an Iterator.
A simple path is one in which each vertex in the path is distinct.
with⁡GraphTheory:
C6≔CycleGraph⁡6
C6≔Graph 1: an undirected graph with 6 vertices and 6 edges
IsReachable⁡C6,1,5
true
iter≔AllSimplePaths⁡C6,1,5
iter≔Path Iterator
forpathiniterdoprint⁡pathenddo
1,6,5
1,2,3,4,5
AllSimplePaths⁡C6,1,5,output=set
1,6,5,1,2,3,4,5
W6≔Graph⁡1,2,10,1,6,6,2,3,−10,3,4,10,4,5,−10,5,6,5
W6≔Graph 2: a directed weighted graph with 6 vertices and 6 arcs
DrawGraph⁡W6,layout=circle
AllSimplePaths⁡W6,1,6,output=list
1,6,1,2,3,4,5,6
AllSimplePaths⁡W6,6,1,output=list
The GraphTheory[AllSimplePaths] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
BellmanFordAlgorithm
DijkstrasAlgorithm
Distance
IsReachable
IsSimplePath
Reachable
Download Help Document