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

Graph Traversals

These 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 © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.