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

Vertices

What exactly is a vertex? The answer to this question depends on the application. At the very minimum, every vertex in a graph must be distinguishable from every other vertex in that graph. We can do this by numbering consecutively the vertices of a graph. In addition, some applications require vertex-weighted graphs. A weighted vertex can be viewed as one which carries a ``payload''. The payload is an object that represents the weight on the vertex.

Program gif defines the Vertex interface. The Vertex interface extends the IComparable interface.

   program49209
Program: Vertex interface.

Every vertex in a graph is assigned a unique number. The Number property provides a get accessor that returns the number of a vertex. The Weight property provides a get accessor that returns an object that represents the weight associated with a weighted vertex. If the vertex is is unweighted, the Weight property is returns null.




next up previous contents index

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