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

Graphs and Digraphs

Directed graphs and undirected graphs have many common characteristics. In addition, we can view a directed graph as an undirected graph with arrowheads added. As shown in Figure gif, we have chosen to define the Graph interface to represent undirected graphs and to derive Digraph interface from it. We have chosen this approach because many algorithms for undirected graphs can also be used with directed graphs. On the other hand, it is often the case that algorithms for directed graphs cannot be used with undirected graphs.

Program gif defines the Graph interface. The Graph interface extends the Container interface defined in Program gif.

   program49293
Program: Graph interface.

There are essentially three groups of methods declared in Program gif: accessors and mutators, enumerators, and traversals. The operations performed by the methods are explained in the following sections.




next up previous contents index

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