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

Accessors and Mutators

The Graph interface declares the following accessor properties and mutator methods:

NumberOfEdges
This property provides a get accessor that returns the number of edges contained by the graph.
NumberOfVertices
This property provides a get accessor that returns the number of vertices contained by the graph.
IsDirected
This bool-valued property is true if the graph is a directed graph.
AddVertex
This method inserts a vertex into a graph. All the vertices contained in a given graph must have a unique vertex number. Furthermore, if a graph contains n vertices, those vertices shall be numbered 0, 1, ..., n-1. Therefore, the next vertex inserted into the graph shall have the number n.
GetVertex
This method takes an integer, say i where tex2html_wrap_inline61825, and returns the tex2html_wrap_inline57621 vertex contained in the graph.
AddEdge
This method inserts an edge into a graph. If the graph contains n vertices, both arguments must fall in the interval [0,n-1].
IsEdge
This bool-valued method takes two integer arguments. It returns true if the graph contains an edge that connects the corresponding vertices.
GetEdge
This method takes two integer arguments. It returns the edge instance (if it exists) that connects the corresponding vertices. The behavior of this method is undefined when the edge does not exist. (An implementation will typically throw an exception).
IsCyclic
This bool-valued property is true if the graph is cyclic.
IsConnected
This bool-valued property is true if the graph is connected. Connectedness of graphs is discussed in Section gif.


next up previous contents index

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