Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Graph Traversals

The following traversal methods are analogous to the Accept method of the container class (see Section gif). Each of these methods takes a visitor and performs a traversal. That is, all the vertices of the graph are visited systematically. When a vertex is visited, the Visit method of the visitor is applied to that vertex.

DepthFirstTraversal
This methods accepts two arguments--a PrePostVisitor and an integer. The integer specifies the starting vertex for a depth-first traversal of the graph.
BreadthFirstTraversal
This methods accepts two arguments--a Visitor and an integer. The integer specifies the starting vertex for a breadth-first traversal of the graph.

Graph traversal algorithms are discussed in Section gif.


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.