Traverse - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

Traverse

  

traverse vertices of a graph

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

Traverse(G, t, opts)

Parameters

G

-

graph

t

-

(optional) one of breadthfirst or depthfirst; default is breadthfirst

opts

-

(optional) one or more options as specified below

Options

• 

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.

Description

• 

Traverse(G,t) returns a list or Iterator encoding a particular traversal of the vertices of G.

Examples

withGraphTheory:

C4CycleGraph4

C4Graph 1: an undirected graph with 4 vertices and 4 edge(s)

(1)

TraverseC4

1,2,3,4

(2)

itTraverseC4,output=iterator

itObject<<140474922738496>>

(3)

GGraphTheory:-Graph8&comma;2&comma;3&comma;2&comma;5&comma;3&comma;6&comma;6&comma;7

GGraph 2: an undirected graph with 8 vertices and 4 edge(s)

(4)

TraverseG&comma;breadthfirst

1&comma;2&comma;3&comma;5&comma;6&comma;7&comma;4&comma;8

(5)

TraverseG&comma;depthfirst

1&comma;2&comma;3&comma;6&comma;7&comma;5&comma;4&comma;8

(6)

TraverseG&comma;connected

1

(7)

TraverseG&comma;connected&comma;startvertex=2

2&comma;3&comma;5&comma;6&comma;7

(8)

Compatibility

• 

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