Class AbstractGraph

java.lang.Object
  extended by AbstractGraph
Direct Known Subclasses:
MyGraph

public abstract class AbstractGraph
extends java.lang.Object

This class represents an abstract graph structure. It is largely stolen from our CSC 210 textbook by Koffman & Wolfgang.

Author:
William Krieger

Field Summary
protected  int numVerts
          Number of vertices in the graph
 
Constructor Summary
AbstractGraph(int numVerts)
          Create a graph with the specified number of vertices.
 
Method Summary
abstract  void addEdge(Edge e)
           
abstract  AbstractGraph createGraph(int numVerts)
          Factory method creates a new graph.
abstract  java.util.Iterator<Edge> edgeIterator(int v1)
           
abstract  Edge getEdge(int v1, int v2)
           
 int getNumVerts()
          Returns the number of vertices in the graph.
abstract  boolean hasEdge(int v1, int v2)
           
abstract  void removeAllEdges()
           
abstract  void removeEdge(Edge e)
           
abstract  void setAllEdgeWeights(double w)
           
 java.lang.String toString()
          Returns a debugging string for the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numVerts

protected int numVerts
Number of vertices in the graph

Constructor Detail

AbstractGraph

public AbstractGraph(int numVerts)
Create a graph with the specified number of vertices.

Parameters:
numVerts - Number of vertices in the new graph.
Method Detail

getNumVerts

public int getNumVerts()
Returns the number of vertices in the graph.

Returns:
The number of vertices.

createGraph

public abstract AbstractGraph createGraph(int numVerts)
Factory method creates a new graph.

Parameters:
numVerts - Number of vertices in the new graph.
Returns:
Returns a new graph.

addEdge

public abstract void addEdge(Edge e)

removeEdge

public abstract void removeEdge(Edge e)

removeAllEdges

public abstract void removeAllEdges()

hasEdge

public abstract boolean hasEdge(int v1,
                                int v2)

getEdge

public abstract Edge getEdge(int v1,
                             int v2)

setAllEdgeWeights

public abstract void setAllEdgeWeights(double w)

edgeIterator

public abstract java.util.Iterator<Edge> edgeIterator(int v1)

toString

public java.lang.String toString()
Returns a debugging string for the graph.

Overrides:
toString in class java.lang.Object
Returns:
Debugging string for the graph.