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

Iterators

All the other container classes considered in this text have only one associated iterator. When dealing with graphs, it is convenient to have at least four iterators: The first two are used to enumerate the sets tex2html_wrap_inline71357 and tex2html_wrap_inline71363, and the last two are used to enumerate the sets tex2html_wrap_inline71425 and tex2html_wrap_inline71457 associated with a given vertex v.

Each of the following member functions allocates dynamically a new iterator instance as follows:

Vertices
This member function of the Graph class returns an iterator that can be used to traverse the elements of tex2html_wrap_inline71357.
Edges
This member function of the Graph class returns an iterator that can be used to traverse the elements of tex2html_wrap_inline71363.
IncidentEdges
This member function takes a reference to a vertex, say v, and returns an iterator that can be used to traverse the elements of tex2html_wrap_inline71457. The vertex v must be contained by the graph.
EmanatingEdges
This member function takes a reference to a vertex, say v, and returns an iterator that can be used to traverse the elements of tex2html_wrap_inline71425. The vertex v must be contained by the graph.


next up previous contents index

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