scratch.tom.simpleGraph
Class DefaultGraph<V,E extends Edge<V>>

java.lang.Object
  extended by scratch.tom.simpleGraph.DefaultGraph<V,E>
Type Parameters:
V - type of the vertices
E - type of the edges
All Implemented Interfaces:
Graph<V,E>

public class DefaultGraph<V,E extends Edge<V>>
extends Object
implements Graph<V,E>

an example implementation of Graph

Author:
Tom Nelson - RABA Technologies

Constructor Summary
DefaultGraph()
           
 
Method Summary
 void addEdge(E edge)
          note that vertices in the new edge are added to the graph if not there already
 void addEdges(Collection<E> edges)
          note that vertices in the new edges are added to the graph if not there already
 void addVertex(V vertex)
           
 void addVertices(Collection<V> vertices)
           
 int getEdgeCount()
           
 Collection<E> getEdges()
           
 int getVertexCount()
           
 Collection<V> getVertices()
           
 boolean removeEdge(E edge)
           
 boolean removeEdges(Collection<E> edges)
           
 boolean removeVertex(V vertex)
          remove the vertex.
 boolean removeVertices(Collection<V> vertices)
          remove all vertices in the passed collection, If any existing edges contain any vertices from the passed collection, remove those edges, too.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGraph

public DefaultGraph()
Method Detail

getVertices

public Collection<V> getVertices()
Specified by:
getVertices in interface Graph<V,E extends Edge<V>>

getEdges

public Collection<E> getEdges()
Specified by:
getEdges in interface Graph<V,E extends Edge<V>>

getVertexCount

public int getVertexCount()

getEdgeCount

public int getEdgeCount()

addVertex

public void addVertex(V vertex)
Specified by:
addVertex in interface Graph<V,E extends Edge<V>>

removeVertex

public boolean removeVertex(V vertex)
remove the vertex. If the vertex is an endpoint of an existing edge, remove the edge

Specified by:
removeVertex in interface Graph<V,E extends Edge<V>>

addVertices

public void addVertices(Collection<V> vertices)
Specified by:
addVertices in interface Graph<V,E extends Edge<V>>

removeVertices

public boolean removeVertices(Collection<V> vertices)
remove all vertices in the passed collection, If any existing edges contain any vertices from the passed collection, remove those edges, too.

Specified by:
removeVertices in interface Graph<V,E extends Edge<V>>

addEdge

public void addEdge(E edge)
note that vertices in the new edge are added to the graph if not there already

Specified by:
addEdge in interface Graph<V,E extends Edge<V>>

removeEdge

public boolean removeEdge(E edge)
Specified by:
removeEdge in interface Graph<V,E extends Edge<V>>

addEdges

public void addEdges(Collection<E> edges)
note that vertices in the new edges are added to the graph if not there already

Specified by:
addEdges in interface Graph<V,E extends Edge<V>>

removeEdges

public boolean removeEdges(Collection<E> edges)
Specified by:
removeEdges in interface Graph<V,E extends Edge<V>>