salvo.jesus.graph
Class DirectedGraphWeakImpl

java.lang.Object
  extended by salvo.jesus.graph.DirectedGraphWeakImpl
All Implemented Interfaces:
java.io.Serializable, DirectedGraph, Graph

 class DirectedGraphWeakImpl
extends java.lang.Object
implements DirectedGraph

A weak implementation of the DirectedGraph interface.

Author:
Jesus M. Salvo Jr., Francois Taiani

Field Summary
(package private)  GraphImpl graph
          The GraphImpl object which has delegated the DirectedGraph interface implementation to this object - DirectedGraphWeakImpl.
(package private)  java.util.Map incomingEdges
          Vector of incoming edges in the graph.
(package private)  java.util.Map outgoingEdges
          Vector of outgoing edges in the graph.
 
Constructor Summary
DirectedGraphWeakImpl(GraphImpl graph)
          Creates a new instance of DirectedGraphWeakImpl.
DirectedGraphWeakImpl(GraphImpl graph, DirectedGraphWeakImpl toBeCopied)
          Copy constructor
 
Method Summary
 void add(Vertex newvertex)
          Adds a new Vector in both the incoming and outgoing Vector of Edges.
protected  void addEdge(DirectedEdge dedge)
          Adds the Edge created as an outgoing edge of one vertex and as an incoming edge of the other vertex.
 void addEdge(Edge edge)
          Empty method implemetation that does nothing.
 Edge addEdge(Vertex v1, Vertex v2)
          Empty method implemetation that returns null.
 void addGraphAddEdgeListener(GraphAddEdgeListener listener)
          Empty method implemetation that returns null.
 void addGraphAddVertexListener(GraphAddVertexListener listener)
          Empty method implemetation that returns null.
 void addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
          Empty method implemetation that returns null.
 void addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
          Empty method implemetation that returns null.
 java.util.Collection cloneVertices()
          Empty method implemetation that returns null.
 Edge createEdge(Vertex v1, Vertex v2)
          Empty method implemetation that returns null.
 java.util.Collection getAdjacentVertices(java.util.Collection vertices)
          Empty method implemetation that returns null.
 java.util.Collection getAdjacentVertices(Vertex v)
          Empty method implemetation that returns null.
private  java.util.Collection getAdjacentVertices(Vertex v, boolean outGoing)
          Returns the vertices that are adjacent to a specified Vertex, respecting the direction of the Edge from the specified Vertex.
 java.util.Collection getConnectedSet()
          Empty method implemetation that returns null.
 java.util.Collection getConnectedSet(Vertex v)
          Empty method implemetation that returns null.
 int getDegree()
          Empty method implemetation that returns 0.
 int getDegree(Vertex v)
          Empty method implemetation that returns 0.
 DirectedEdge getEdge(Vertex fromvertex, Vertex tovertex)
          Returns an Edge in the Graph whose origin is fromVertex and destination is toVertex.
 java.util.Collection getEdges(Vertex v)
          Empty method implemetation that returns null.
 java.util.Collection getIncomingAdjacentVertices(Vertex v)
          Returns the vertices that are adjacent to a specified Vertex where the Edge is incoming from the specified Vertex to the adjacent vertex.
protected  java.util.Map getIncomingEdges()
          Returns the incoming EdgeSets of the Graph.
 java.util.Collection getIncomingEdges(Vertex v)
          Returns the incoming edges of a particular Vertex in the Graph.
 java.util.Collection getOutgoingAdjacentVertices(Vertex v)
          Returns the vertices that are adjacent to a specified Vertex where the Edge is outgoing from the specified Vertex to the adjacent vertex.
protected  java.util.Map getOutgoingEdges()
          Returns the outgoing EdgeSets of the Graph.
 java.util.Collection getOutgoingEdges(Vertex v)
          Returns the outgoing edges of a particular Vertex in the Graph.
 GraphTraversal getTraversal()
          Empty method implemetation that returns null.
 java.util.Set getVertices(int degree)
          Empty method implemetation that returns null.
 int getVerticesCount()
          Empty method implemetation that returns 0.
 java.util.Iterator getVerticesIterator()
          Empty method implemetation that returns null.
 boolean isConnected(Vertex v1, Vertex v2)
          Empty method implemetation that returns false.
 boolean isCycle(Vertex fromVertex)
          Determines if there is a cycle from Vertex fromVertex.
 boolean isPath(Vertex fromVertex, Vertex toVertex)
          Determines if there is a path from Vertex fromVertex to Vertex toVertex.
 void mergeconnectedSet(Vertex v1, Vertex v2)
          Empty method implemetation that returns null.
 void remove(Vertex someVertex)
          Removes the vertex's vectors of incoming and outgoing edges..
protected  void removeEdge(DirectedEdge dedge)
          Removes the Edge as the incoming and outgoing edge of the vertices at the ends of the Edge.
 void removeEdge(Edge e)
          Empty method implemetation that returns null.
 void removeEdges(Vertex v)
          Empty method implemetation that returns null.
 void removeGraphAddEdgeListener(GraphAddEdgeListener listener)
          Empty method implemetation that returns null.
 void removeGraphAddVertexListener(GraphAddVertexListener listener)
          Empty method implemetation that returns null.
 void removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
          Empty method implemetation that returns null.
 void removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
          Empty method implemetation that returns null.
 void setTraversal(GraphTraversal traversal)
          Empty method implemetation that returns null.
 java.util.Vector traverse(Vertex startat)
          Empty method implemetation that returns null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

GraphImpl graph
The GraphImpl object which has delegated the DirectedGraph interface implementation to this object - DirectedGraphWeakImpl.


outgoingEdges

java.util.Map outgoingEdges
Vector of outgoing edges in the graph. The index of a Vertex in the vertices Vector matches the Vertex's outgoing edges index in the Vector outgoingEdges.


incomingEdges

java.util.Map incomingEdges
Vector of incoming edges in the graph. The index of a Vertex in the vertices Vector matches the Vertex's incoming edges index in the Vector incomingEdges.

Constructor Detail

DirectedGraphWeakImpl

public DirectedGraphWeakImpl(GraphImpl graph)
Creates a new instance of DirectedGraphWeakImpl.


DirectedGraphWeakImpl

public DirectedGraphWeakImpl(GraphImpl graph,
                             DirectedGraphWeakImpl toBeCopied)
Copy constructor

Method Detail

getOutgoingEdges

protected java.util.Map getOutgoingEdges()
Returns the outgoing EdgeSets of the Graph. Each element in the return Vector is of type EdgeSet. The index of a Vertex in the vertices Vector matches the Vertex's EdgeSet index in the outgoingEdges Vector.

Returns:
Vector containing the outgoing EdgeSets in the Graph. This simply returns this.adjacentEdges.

getIncomingEdges

protected java.util.Map getIncomingEdges()
Returns the incoming EdgeSets of the Graph. Each element in the return Vector is of type EdgeSet. The index of a Vertex in the vertices Vector matches the Vertex's EdgeSet index in the incomingEdges Vector.

Returns:
Vector containing the incoming EdgeSets in the Graph. This simply returns this.adjacentEdges.

getOutgoingEdges

public java.util.Collection getOutgoingEdges(Vertex v)
Returns the outgoing edges of a particular Vertex in the Graph.

Specified by:
getOutgoingEdges in interface DirectedGraph
Parameters:
v - Vertex you want to determine its outgoing edges.
Returns:
Vector of outgoing edges of the specified Vertex.

getIncomingEdges

public java.util.Collection getIncomingEdges(Vertex v)
Returns the incoming edges of a particular Vertex in the Graph.

Specified by:
getIncomingEdges in interface DirectedGraph
Parameters:
v - Vertex you want to determine its incoming edges.
Returns:
Vector of incoming edges of the specified Vertex.

getAdjacentVertices

private java.util.Collection getAdjacentVertices(Vertex v,
                                                 boolean outGoing)
Returns the vertices that are adjacent to a specified Vertex, respecting the direction of the Edge from the specified Vertex.

Parameters:
v - Vertex you want to determine its outgoing adjacent vertices.
outGoing - If true, method will return outgoing adjacent vertices. If false, method will return incoming adjacent vertices.
Returns:
Vector of outgoing / incoming vertices adjacent to the specified Vertex.

getOutgoingAdjacentVertices

public java.util.Collection getOutgoingAdjacentVertices(Vertex v)
Returns the vertices that are adjacent to a specified Vertex where the Edge is outgoing from the specified Vertex to the adjacent vertex.

Specified by:
getOutgoingAdjacentVertices in interface DirectedGraph
Parameters:
v - Vertex you want to determine its outgoing adjacent vertices.
Returns:
Vector of outgoing vertices adjacent to the specified Vertex.

getIncomingAdjacentVertices

public java.util.Collection getIncomingAdjacentVertices(Vertex v)
Returns the vertices that are adjacent to a specified Vertex where the Edge is incoming from the specified Vertex to the adjacent vertex.

Specified by:
getIncomingAdjacentVertices in interface DirectedGraph
Parameters:
v - Vertex you want to determine its incoming adjacent vertices.
Returns:
Vector of incoming vertices adjacent to the specified Vertex.

getEdge

public DirectedEdge getEdge(Vertex fromvertex,
                            Vertex tovertex)
Returns an Edge in the Graph whose origin is fromVertex and destination is toVertex. If there is more than one Edge that has the same origin and destination in the Graph, the first matching Edge is returned.

Specified by:
getEdge in interface DirectedGraph
Parameters:
fromVertex - Vertex that is the origin of the directed Edge
toVertex - Vertex that is the destination of the directed Edge
Returns:
Edge whose origin is fromVertex and destination is toVertex
See Also:
Edge

isPath

public boolean isPath(Vertex fromVertex,
                      Vertex toVertex)
Determines if there is a path from Vertex fromVertex to Vertex toVertex. This will not return true if the only path has at least one Edge pointing in the opposite direction of the path.

Specified by:
isPath in interface DirectedGraph
Parameters:
fromVertex - starting Vertex for the path
toVertex - ending Vertex for the path
Returns:
true if there is a path from Vertex to toVertex. false otherwise.

isCycle

public boolean isCycle(Vertex fromVertex)
Determines if there is a cycle from Vertex fromVertex. A cycle occurs when there is a path from the specified Vertex back to itself, taking into consideration that direction of the Edges along the path.

Specified by:
isCycle in interface DirectedGraph
Parameters:
fromVertex - Vertex to be tested for a cycle path.
Returns:
true if there is a cycle path from fromVertex to itself.

add

public void add(Vertex newvertex)
Adds a new Vector in both the incoming and outgoing Vector of Edges. The two new vectors added will hold the new vertex's incoming and outgoing edges.

Specified by:
add in interface Graph
Parameters:
newvertex - The Vertex object to be added to the graph.

remove

public void remove(Vertex someVertex)
Removes the vertex's vectors of incoming and outgoing edges..

Specified by:
remove in interface Graph
Parameters:
someVertex - vertex to be removed

addEdge

protected void addEdge(DirectedEdge dedge)
Adds the Edge created as an outgoing edge of one vertex and as an incoming edge of the other vertex.

Parameters:
fromVertex - Vertex that will be the source of the Edge
toVertex - Vertex that will be the sink of the Edge

removeEdge

protected void removeEdge(DirectedEdge dedge)
Removes the Edge as the incoming and outgoing edge of the vertices at the ends of the Edge.

Parameters:
edge - Edge to be removed from the Graph

getVerticesCount

public int getVerticesCount()
Empty method implemetation that returns 0. This method should never be called or delegated to for whatever reason.

Specified by:
getVerticesCount in interface Graph
Returns:
The number of vertices in the graph.

getVerticesIterator

public java.util.Iterator getVerticesIterator()
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getVerticesIterator in interface Graph
Returns:
An iterator of Vector vertices.

cloneVertices

public java.util.Collection cloneVertices()
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
cloneVertices in interface Graph
Returns:
A clone of the Vector of vertices.

createEdge

public Edge createEdge(Vertex v1,
                       Vertex v2)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
createEdge in interface Graph
Parameters:
v1 - One endpoint of the edge
v2 - Other endpoint of the edge

addEdge

public Edge addEdge(Vertex v1,
                    Vertex v2)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
addEdge in interface Graph
Parameters:
v1 - One endpoint of the edge
v2 - Other endpoint of the edge
Returns:
The Edge object created and added to the Graph.

addEdge

public void addEdge(Edge edge)
Empty method implemetation that does nothing. This method should never be called or delegated to for whatever reason.

Specified by:
addEdge in interface Graph
Parameters:
edge - The edge to be added to the Graph.

removeEdge

public void removeEdge(Edge e)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeEdge in interface Graph
Parameters:
e - The Edge object to be removed.

removeEdges

public void removeEdges(Vertex v)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeEdges in interface Graph
Parameters:
v - Vertex whose Edges are to be removed

getDegree

public int getDegree()
Empty method implemetation that returns 0. This method should never be called or delegated to for whatever reason.

Specified by:
getDegree in interface Graph
Returns:
An int indicating the degree of the graph.

getDegree

public int getDegree(Vertex v)
Empty method implemetation that returns 0. This method should never be called or delegated to for whatever reason.

Specified by:
getDegree in interface Graph
Returns:
The degree of the vertex.

getVertices

public java.util.Set getVertices(int degree)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getVertices in interface Graph
Parameters:
degree - The degree of the vertex to be returned.
Returns:
A collection of vertices with the above specified degree.

getEdges

public java.util.Collection getEdges(Vertex v)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getEdges in interface Graph
Parameters:
v - The vertex whose edges we want returned
Returns:
A Vector of Edges that are incident edges of the specified vertex.

getAdjacentVertices

public java.util.Collection getAdjacentVertices(Vertex v)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getAdjacentVertices in interface Graph
Parameters:
v - The Vertex you want to determine its adjacent vertices.
Returns:
Vector of vertices adjacent to the specified vertex v.

getAdjacentVertices

public java.util.Collection getAdjacentVertices(java.util.Collection vertices)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getAdjacentVertices in interface Graph
Parameters:
vertices - Vector of Vertex where each vertex in the returned Set must be adjacent to.
Returns:
Set of vertices adjacent to all the vertices in the supplied Vector.

getConnectedSet

public java.util.Collection getConnectedSet()
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getConnectedSet in interface Graph
Returns:
Vector of Vector of connected vertices.

getConnectedSet

public java.util.Collection getConnectedSet(Vertex v)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getConnectedSet in interface Graph
Parameters:
v - Vertex to which you want the connected set returned.
Returns:
Vector of connected vertices where the specified vertex belongs.

mergeconnectedSet

public void mergeconnectedSet(Vertex v1,
                              Vertex v2)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
mergeconnectedSet in interface Graph
Parameters:
v1 - Vertex whose connected set you want merged with the connected set of Vertex v2.
v2 - Vertex whose connected set you want merged with the connected set of Vertex v1.

traverse

public java.util.Vector traverse(Vertex startat)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
traverse in interface Graph
Parameters:
startat - The Vertex to which you want to start the traversal.

getTraversal

public GraphTraversal getTraversal()
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
getTraversal in interface Graph
Returns:
GraphTraversal object performing traversal for the Graph.

setTraversal

public void setTraversal(GraphTraversal traversal)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
setTraversal in interface Graph
Parameters:
traversal - A concrete implementation of the GraphTraversal object.

isConnected

public boolean isConnected(Vertex v1,
                           Vertex v2)
Empty method implemetation that returns false. This method should never be called or delegated to for whatever reason.

Specified by:
isConnected in interface Graph
Parameters:
v1 - starting Vertex for the path
v2 - ending Vertex for the path
Returns:
true if v1 and v2 are connected.

addGraphAddVertexListener

public void addGraphAddVertexListener(GraphAddVertexListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
addGraphAddVertexListener in interface Graph
Parameters:
listener - GraphAddVertexListener you want registered or be notified when a new Vertex is added
See Also:
GraphAddVertexListener, Graph.removeGraphAddVertexListener( GraphAddVertexListener )

addGraphAddEdgeListener

public void addGraphAddEdgeListener(GraphAddEdgeListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
addGraphAddEdgeListener in interface Graph
Parameters:
listener - GraphAddEdgeListener you want registered or be notified when a new Edge is added
See Also:
GraphAddEdgeListener, Graph.removeGraphAddEdgeListener( GraphAddEdgeListener )

addGraphRemoveEdgeListener

public void addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
addGraphRemoveEdgeListener in interface Graph
Parameters:
listener - GraphRemoveEdgeListener you want registered or be notified when an Edge is removed
See Also:
GraphRemoveEdgeListener, Graph.removeGraphRemoveEdgeListener( GraphRemoveEdgeListener )

addGraphRemoveVertexListener

public void addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
addGraphRemoveVertexListener in interface Graph
Parameters:
listener - GraphRemoveVertexListener you want registered or be notified when a Vertex is removed
See Also:
GraphRemoveVertexListener, Graph.removeGraphRemoveVertexListener( GraphRemoveVertexListener )

removeGraphAddVertexListener

public void removeGraphAddVertexListener(GraphAddVertexListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeGraphAddVertexListener in interface Graph
Parameters:
listener - GraphAddVertexListener you no longer want registered or be notified when a Vertex is added
See Also:
GraphAddVertexListener, Graph.addGraphAddVertexListener( GraphAddVertexListener )

removeGraphAddEdgeListener

public void removeGraphAddEdgeListener(GraphAddEdgeListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeGraphAddEdgeListener in interface Graph
Parameters:
listener - GraphAddEdgeListener you no longer want registered or be notified when an Edge is added
See Also:
GraphAddEdgeListener, Graph.addGraphAddEdgeListener( GraphAddEdgeListener )

removeGraphRemoveEdgeListener

public void removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeGraphRemoveEdgeListener in interface Graph
Parameters:
listener - GraphRemoveEdgeListener you no longer want registered or be notified when an Edge is removed
See Also:
GraphRemoveEdgeListener, Graph.addGraphRemoveEdgeListener( GraphRemoveEdgeListener )

removeGraphRemoveVertexListener

public void removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Empty method implemetation that returns null. This method should never be called or delegated to for whatever reason.

Specified by:
removeGraphRemoveVertexListener in interface Graph
Parameters:
listener - GraphRemoveVertexListener you no longer want registered or be notified when a Vertex is removed
See Also:
GraphRemoveVertexListener, Graph.addGraphRemoveVertexListener( GraphRemoveVertexListener )