Opus5
Class GraphAsLists

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

public class GraphAsLists
extends AbstractGraph

An undirected graph implemented using adjacency lists.

Version:
$Id: GraphAsLists.java,v 3.4 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  LinkedList[] adjacencyList
          The adjacency lists.
 
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
GraphAsLists(int size)
          Constructs a GraphAsLists 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 in this graph that connects the specified vertices.
 Enumeration getEdges()
          Returns an enumeration that enumerates the edges of this graph.
protected  Enumeration getEmanatingEdges(int v)
          Returns an enumeration that enumerates the edges that emanate from the specified vertex in this graph.
protected  Enumeration getIncidentEdges(int v)
          Returns an enumeration that enumerates the edges incident upon the specified vertex in this graph.
 boolean isEdge(int v, int w)
          Tests whethere 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

adjacencyList

protected LinkedList[] adjacencyList
The adjacency lists.
Constructor Detail

GraphAsLists

public GraphAsLists(int size)
Constructs a GraphAsLists 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 this graph.

getEdge

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

isEdge

public boolean isEdge(int v,
                      int w)
Tests whethere 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.

getIncidentEdges

protected Enumeration getIncidentEdges(int v)
Returns an enumeration that enumerates the edges incident upon the specified vertex in this graph. This method is not implemented.
Overrides:
getIncidentEdges in class AbstractGraph
Parameters:
v - The number of the specified vertex.
Throws:
MethodNotImplemented - Always.

getEdges

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

getEmanatingEdges

protected Enumeration getEmanatingEdges(int v)
Returns an enumeration that enumerates the edges that emanate from the specified vertex in this graph.
Overrides:
getEmanatingEdges in class AbstractGraph
Parameters:
v - The number of the specified vertex.
Returns:
An enumeration that enumerates the edges that emanate from the specified vertex in this graph.

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:
The - comparable object with which to compare this graph.
Throws:
MethodNotImplemented - Always.