org._3pq.jgrapht.edge
Class DefaultEdge

java.lang.Object
  |
  +--org._3pq.jgrapht.edge.DefaultEdge
All Implemented Interfaces:
java.lang.Cloneable, Edge
Direct Known Subclasses:
DirectedEdge, UndirectedEdge

public class DefaultEdge
extends java.lang.Object
implements Edge, java.lang.Cloneable

A skeletal implementation of the Edge interface, to minimize the effort required to implement the interface.

Since:
Jul 14, 2003
Author:
Barak Naveh

Fields inherited from interface org._3pq.jgrapht.Edge
DEFAULT_EDGE_WEIGHT
 
Constructor Summary
DefaultEdge(java.lang.Object sourceVertex, java.lang.Object targetVertex)
          Constructor for DefaultEdge.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a shallow copy of this edge.
 boolean containsVertex(java.lang.Object v)
          Returns true if this edge contains the specified vertex.
 java.lang.Object getSource()
          Returns the source vertex of this edge.
 java.lang.Object getTarget()
          Returns the target vertex of this edge.
 double getWeight()
          Returns the weight of this edge.
 java.lang.Object oppositeVertex(java.lang.Object v)
          Returns the vertex opposite to the specified vertex.
 void setWeight(double weight)
          Sets the weight of this edge.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEdge

public DefaultEdge(java.lang.Object sourceVertex,
                   java.lang.Object targetVertex)
Constructor for DefaultEdge.
Parameters:
sourceVertex - source vertex of the edge.
targetVertex - target vertex of the edge.
Method Detail

getSource

public java.lang.Object getSource()
Description copied from interface: Edge
Returns the source vertex of this edge.
Specified by:
getSource in interface Edge
See Also:
Edge.getSource()

getTarget

public java.lang.Object getTarget()
Description copied from interface: Edge
Returns the target vertex of this edge.
Specified by:
getTarget in interface Edge
See Also:
Edge.getTarget()

setWeight

public void setWeight(double weight)
Description copied from interface: Edge
Sets the weight of this edge. If this edge is unweighted an UnsupportedOperationException is thrown.
Specified by:
setWeight in interface Edge
See Also:
Edge.setWeight(double)

getWeight

public double getWeight()
Description copied from interface: Edge
Returns the weight of this edge. If this edge is unweighted the value 1.0 is returned.
Specified by:
getWeight in interface Edge
See Also:
Edge.getWeight()

clone

public java.lang.Object clone()
Description copied from interface: Edge
Creates and returns a shallow copy of this edge. The vertices of this edge are not cloned.
Specified by:
clone in interface Edge
Overrides:
clone in class java.lang.Object
See Also:
Edge.clone()

containsVertex

public boolean containsVertex(java.lang.Object v)
Description copied from interface: Edge
Returns true if this edge contains the specified vertex. More formally, returns true if and only if the following condition holds:
      this.getSource().equals(v) || this.getTarget().equals(v)
 
Specified by:
containsVertex in interface Edge
See Also:
Edge.containsVertex(java.lang.Object)

oppositeVertex

public java.lang.Object oppositeVertex(java.lang.Object v)
Description copied from interface: Edge
Returns the vertex opposite to the specified vertex.
Specified by:
oppositeVertex in interface Edge
See Also:
Edge.oppositeVertex(java.lang.Object)