org._3pq.jgrapht

Interface Edge

All Superinterfaces:
Cloneable
Known Implementing Classes:
DefaultEdge, DirectedEdge, DirectedWeightedEdge, UndirectedEdge, UndirectedWeightedEdge

public interface Edge
extends Cloneable

An edge used with graph objects. This is the root interface in the edge hierarchy.

NOTE: the source and target associations of an Edge must be immutable after construction for all implementations. The reason is that once an Edge is added to a Graph, the Graph representation may be optimized via internal indexing data structures; if the Edge associations were to change, these structures would be corrupted. However, other properties of an edge (such as weight or label) may be mutable, although this still requires caution: changes to Edges shared by multiple Graphs may not always be desired, and indexing mechanisms for these properties may require a change notification mechanism.

Author:
Barak Naveh
Since:
Jul 14, 2003

Field Summary

static double
DEFAULT_EDGE_WEIGHT
The default weight for an edge.

Method Summary

Object
clone()
Creates and returns a shallow copy of this edge.
boolean
containsVertex(Object v)
Returns true if this edge contains the specified vertex.
Object
getSource()
Returns the source vertex of this edge.
Object
getTarget()
Returns the target vertex of this edge.
double
getWeight()
Returns the weight of this edge.
Object
oppositeVertex(Object v)
Returns the vertex opposite to the specified vertex.
void
setWeight(double weight)
Sets the weight of this edge.

Field Details

DEFAULT_EDGE_WEIGHT

public static final double DEFAULT_EDGE_WEIGHT
The default weight for an edge.
Field Value:
1.0

Method Details

clone

public Object clone()
Creates and returns a shallow copy of this edge. The vertices of this edge are not cloned.
Returns:
a shallow copy of this edge.
See Also:
Cloneable

containsVertex

public boolean containsVertex(Object v)
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)
 
Parameters:
v - vertex whose presence in this edge is to be tested.
Returns:
true if this edge contains the specified vertex.

getSource

public Object getSource()
Returns the source vertex of this edge.
Returns:
the source vertex of this edge.

getTarget

public Object getTarget()
Returns the target vertex of this edge.
Returns:
the target vertex of this edge.

getWeight

public double getWeight()
Returns the weight of this edge. If this edge is unweighted the value 1.0 is returned.
Returns:
the weight of this element.

oppositeVertex

public Object oppositeVertex(Object v)
Returns the vertex opposite to the specified vertex.
Parameters:
v - the vertex whose opposite is required.
Returns:
the vertex opposite to the specified vertex.

setWeight

public void setWeight(double weight)
Sets the weight of this edge. If this edge is unweighted an UnsupportedOperationException is thrown.
Parameters:
weight - new weight.