Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
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 defines the Vertex interface. The Vertex interface extends the IComparable 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.