salvo.jesus.graph
Class SimplePathImpl

java.lang.Object
  extended by salvo.jesus.graph.GraphImpl
      extended by salvo.jesus.graph.PathImpl
          extended by salvo.jesus.graph.SimplePathImpl
All Implemented Interfaces:
java.io.Serializable, Graph, Path, SimplePath

public class SimplePathImpl
extends PathImpl
implements SimplePath

Implementation of SimplePath interface guaranteeing that the path is simple, meaning no Vertex is repeated in the path.

Author:
Jesus M. Salvo Jr.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class salvo.jesus.graph.PathImpl
vertexStack
 
Fields inherited from class salvo.jesus.graph.GraphImpl
addedgelistener, addvertexlistener, connectedSetS, edges, removeedgelistener, removevertexlistener, traversal, vertices
 
Constructor Summary
SimplePathImpl()
          Creates an instance of SimplePathImpl.
 
Method Summary
 void add(Vertex newVertex)
          Adds a Vertex into the Path.
 void addEdge(Edge edge)
          Adds an Edge into Path.
private  void validatePath(Vertex vertex)
          Throws an exception if the vertex being added will result in a non-simple path.
 
Methods inherited from class salvo.jesus.graph.PathImpl
getFirstVertex, getLastVertex, remove, remove, removeEdge, removeEdges, toString
 
Methods inherited from class salvo.jesus.graph.GraphImpl
addEdge, addGraphAddEdgeListener, addGraphAddVertexListener, addGraphRemoveEdgeListener, addGraphRemoveVertexListener, clone, cloneVertices, createEdge, getAdjacentVertices, getAdjacentVertices, getConnectedSet, getConnectedSet, getDegree, getDegree, getEdges, getTraversal, getVertices, getVerticesCount, getVerticesIterator, isConnected, mergeconnectedSet, removeGraphAddEdgeListener, removeGraphAddVertexListener, removeGraphRemoveEdgeListener, removeGraphRemoveVertexListener, setTraversal, traverse
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface salvo.jesus.graph.Path
getFirstVertex, getLastVertex, remove
 
Methods inherited from interface salvo.jesus.graph.Graph
addEdge, addGraphAddEdgeListener, addGraphAddVertexListener, addGraphRemoveEdgeListener, addGraphRemoveVertexListener, cloneVertices, createEdge, getAdjacentVertices, getAdjacentVertices, getConnectedSet, getConnectedSet, getDegree, getDegree, getEdges, getTraversal, getVertices, getVerticesCount, getVerticesIterator, isConnected, mergeconnectedSet, remove, removeEdge, removeEdges, removeGraphAddEdgeListener, removeGraphAddVertexListener, removeGraphRemoveEdgeListener, removeGraphRemoveVertexListener, setTraversal, traverse
 

Constructor Detail

SimplePathImpl

public SimplePathImpl()
Creates an instance of SimplePathImpl.

Method Detail

add

public void add(Vertex newVertex)
         throws java.lang.Exception
Adds a Vertex into the Path. This method ensures that the resulting Path is still simple. If not, an IllegalPathException is thrown.

If adding this new Edge instance is not desired and you want to add an existing Edge instance instead ( i.e.: from an Edge in a Graph ), then you should call addEdge( Edge ) instead.

Specified by:
add in interface Graph
Overrides:
add in class PathImpl
Parameters:
newvertex - Vertex to be added to the Path
Throws:
IllegalPathException - Thrown if adding the Vertex will result to a non-simple Path.
java.lang.Exception

addEdge

public void addEdge(Edge edge)
             throws java.lang.Exception
Adds an Edge into Path. This method ensures that the resulting Path is still simple. If not, an IllegalPathException is thrown.

Specified by:
addEdge in interface Graph
Overrides:
addEdge in class PathImpl
Parameters:
edge - The edge to be added to the Graph.
Throws:
IllegalPathException - Thrown when the vertexA property of the Edge being added is not the last Vertex in the path.
java.lang.Exception

validatePath

private void validatePath(Vertex vertex)
                   throws IllegalPathException
Throws an exception if the vertex being added will result in a non-simple path. Otherwise, returns true.

Throws:
IllegalPathException