Opus5
Class GraphAsMatrix

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractGraph
                    |
                    +--Opus5.GraphAsMatrix
All Implemented Interfaces:
Comparable, Container, Graph
Direct Known Subclasses:
DigraphAsMatrix

public class GraphAsMatrix
extends AbstractGraph

An undirected graph implemented using an adjacency matrix.

Version:
$Id: GraphAsMatrix.java,v 3.3 1998/07/28 03:02:23 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Inner classes inherited from class Opus5.AbstractGraph
AbstractGraph.Counter, AbstractGraph.GraphEdge, AbstractGraph.GraphVertex
 
Field Summary
protected  Edge[][] matrix
          The adjacency matrix.
 
Fields inherited from class Opus5.AbstractGraph
numberOfEdges, numberOfVertices, vertex
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.Graph
copyright
 
Constructor Summary
GraphAsMatrix(int size)
          Constructs a GraphAsMatrix with the specified size.
 
Method Summary
protected  void addEdge(Edge edge)
          Adds the specified edge to this graph.
protected  int compareTo(Comparable arg)
          Compares this graph with the specified comparable object.
 Edge getEdge(int v, int w)
          Returns the edge that connects the specified vertices.
 Enumeration getEdges()
          Returns an enumeration that enumerates the edges in this graph.
protected  Enumeration getEmanatingEdges(int v)
          Returns an enumeration that enumerates the edges that emanate from the specified vertex.
protected  Enumeration getIncidentEdges(int w)
          Returns an enumeration that enumerates the edges that are incident upon the specified vertex.
 boolean isEdge(int v, int w)
          Tests whether there is an edge in this graph that connects the specified vertices.
 void purge()
          Purges this graph, making it the empty graph.
 
Methods inherited from class Opus5.AbstractGraph
accept, addEdge, addEdge, addVertex, addVertex, addVertex, breadthFirstTraversal, depthFirstTraversal, getEnumeration, getNumberOfEdges, getNumberOfVertices, getVertex, getVertices, isConnected, isCyclic, isDirected, isStronglyConnected, topologicalOrderTraversal, toString
 
Methods inherited from class Opus5.AbstractContainer
getCount, hashCode, isEmpty, isFull
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Container
getCount, isEmpty, isFull
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

matrix

protected Edge[][] matrix
The adjacency matrix.
Constructor Detail

GraphAsMatrix

public GraphAsMatrix(int size)
Constructs a GraphAsMatrix with the specified size.
Parameters:
size - The maximum number of vertices.
Method Detail

purge

public void purge()
Purges this graph, making it the empty graph.
Overrides:
purge in class AbstractGraph

addEdge

protected void addEdge(Edge edge)
Adds the specified edge to this graph.
Overrides:
addEdge in class AbstractGraph
Parameters:
edge - The edge to add to add.
Throws:
java.lang.IllegalArgumentException - If there already is an edge in this graph connected the same vertices or if the edge is a loop.

getEdge

public Edge getEdge(int v,
                    int w)
Returns the edge that connects the specified vertices.
Parameters:
v - A vertex number.
w - A vertex number.
Returns:
The edge that connects the specified vertices.
Throws:
java.lang.IllegalArgumentException - If there is no edge connecting the specified vertices.

isEdge

public boolean isEdge(int v,
                      int w)
Tests whether there is an edge in this graph that connects the specified vertices.
Parameters:
v - A vertex number.
w - A vertex number.
Returns:
True if there is an edge in this graph that connects the specified vertices; false otherwise.

getEdges

public Enumeration getEdges()
Returns an enumeration that enumerates the edges in this graph.
Returns:
an enumeration that enumerates the edges in this graph.

getEmanatingEdges

protected Enumeration getEmanatingEdges(int v)
Returns an enumeration that enumerates the edges that emanate from the specified vertex.
Overrides:
getEmanatingEdges in class AbstractGraph
Returns:
An enumeration that enumerates the edges that emanate from the specified vertex.

getIncidentEdges

protected Enumeration getIncidentEdges(int w)
Returns an enumeration that enumerates the edges that are incident upon the specified vertex.
Overrides:
getIncidentEdges in class AbstractGraph
Returns:
An enumeration that enumerates the edges that are incident upon the specified vertex.

compareTo

protected int compareTo(Comparable arg)
Compares this graph with the specified comparable object. This method is not implemented.
Overrides:
compareTo in class AbstractObject
Parameters:
arg - The object with which to compare this graph.
Throws:
MethodNotImplemented - Alwyas.