salvo.jesus.graph
Class EdgeImpl

java.lang.Object
  extended by salvo.jesus.graph.EdgeImpl
All Implemented Interfaces:
java.io.Serializable, Edge
Direct Known Subclasses:
DirectedEdgeImpl

public class EdgeImpl
extends java.lang.Object
implements Edge

Represents an undirected edge in a graph.

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

Field Summary
protected  java.lang.Object object
          The Object encapsulated by the Edge
protected  Vertex vertexA
          The A vertex of the edge.
protected  Vertex vertexB
          The B vertex of the edge.
 
Constructor Summary
EdgeImpl(Vertex a, Vertex b)
          Creates an UndirectedEdge object.
 
Method Summary
protected  java.lang.Object clone()
          Creates a clone of this Edge.
 java.lang.Object getObject()
          Returns the object encapsulated by the Edge
 Vertex getOppositeVertex(Vertex v)
          Returns the Vertex opposite to the specified Vertex in the edge.
 Vertex getVertexA()
          Returns the endpoint A of the edge.
 Vertex getVertexB()
          Returns the endpoint B of the edge.
 void setObject(java.lang.Object obj)
          Sets an Object that is encapsulated by the Edge
 java.lang.String toString()
          Returns a String representation of the Edge, using the the toString() methods of Vertex.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertexA

protected Vertex vertexA
The A vertex of the edge.


vertexB

protected Vertex vertexB
The B vertex of the edge.


object

protected java.lang.Object object
The Object encapsulated by the Edge

Constructor Detail

EdgeImpl

public EdgeImpl(Vertex a,
                Vertex b)
Creates an UndirectedEdge object.

See Also:
Vertex
Method Detail

getVertexA

public Vertex getVertexA()
Returns the endpoint A of the edge.

Specified by:
getVertexA in interface Edge
Returns:
Vertex Endpoint A of the edge.

getVertexB

public Vertex getVertexB()
Returns the endpoint B of the edge.

Specified by:
getVertexB in interface Edge
Returns:
Vertex Endpoint B of the edge.

getOppositeVertex

public Vertex getOppositeVertex(Vertex v)
Returns the Vertex opposite to the specified Vertex in the edge.

Specified by:
getOppositeVertex in interface Edge
Returns:
Vertex The Vertex object that is the opposite to the specifid Vertex. If the specified Vertex is not an endpoint of the edge, returns null.

setObject

public void setObject(java.lang.Object obj)
Sets an Object that is encapsulated by the Edge

Specified by:
setObject in interface Edge

getObject

public java.lang.Object getObject()
Returns the object encapsulated by the Edge

Specified by:
getObject in interface Edge

toString

public java.lang.String toString()
Returns a String representation of the Edge, using the the toString() methods of Vertex. The format is: fromVertex.toString() + "->" + toVertex.toString()

Specified by:
toString in interface Edge
Overrides:
toString in class java.lang.Object
Returns:
The String representation of the Edge
See Also:
Vertex

clone

protected java.lang.Object clone()
Creates a clone of this Edge. This calls the Edge constructor, thereby creating a new instance of Edge. However, the vertices in both endpoints of the Edge are not cloned.

Overrides:
clone in class java.lang.Object
Returns:
A clone of an instance of Edge.