GraphTheory
Traverse
traverse vertices of a graph
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Traverse(G, t, opts)
G
-
graph
t
(optional) one of breadthfirst or depthfirst; default is breadthfirst
opts
(optional) one or more options as specified below
connected=truefalse
Specifies whether the traversal should be of a connected component. If true, the vertices visited in the traversal are only those reachable from the starting vertex; vertices in other components are not traversed. If false, all vertices in the graph are visited. The default is false.
output=one of iterator or list.
Specifies whether this command returns a list encoding a traversal or an Iterator which will perform the traversal when repeatedly invoked. The default is list.
startvertex=a valid vertex in G
Specifies the starting vertex for a traversal. If not provided, a vertex is chosen by Traverse.
Traverse(G,t) returns a list or Iterator encoding a particular traversal of the vertices of G.
with⁡GraphTheory:
C4≔CycleGraph⁡4
C4≔Graph 1: an undirected graph with 4 vertices and 4 edge(s)
Traverse⁡C4
1,2,3,4
it≔Traverse⁡C4,output=iterator
it≔Object<<140474922738496>>
G≔GraphTheory:-Graph⁡8,2,3,2,5,3,6,6,7
G≔Graph 2: an undirected graph with 8 vertices and 4 edge(s)
Traverse⁡G,breadthfirst
1,2,3,5,6,7,4,8
Traverse⁡G,depthfirst
1,2,3,6,7,5,4,8
Traverse⁡G,connected
1
Traverse⁡G,connected,startvertex=2
2,3,5,6,7
The GraphTheory[Traverse] command was introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
See Also
AllPairsDistance
MinimalSpanningTree
ShortestPath
SpanningTree
Download Help Document