Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Implementing Graphs

In keeping with the design framework used throughout this text, we view graphs as specialized containers. Formally, the graph tex2html_wrap_inline70549 is an ordered pair comprised of two sets--a set of vertices and a set of edges. Informally, we can view a graph as a container with two compartments, one which holds vertices and one which holds edges. There are four kinds of objects--vertices, edges, undirected graphs, and directed graphs. Accordingly, we define four abstract classes: Vertex, Edge, Graph, and Digraph. (See Figure gif).

   figure49438
Figure: Object class hierarchy




next up previous index

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