org._3pq.jgrapht
Interface Edge
- Cloneable
- 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.
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.
|
DEFAULT_EDGE_WEIGHT
public static final double DEFAULT_EDGE_WEIGHT
The default weight for an edge.
clone
public Object clone()
Creates and returns a shallow copy of this edge. The vertices of this
edge are not cloned.
- a shallow copy of this edge.
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)
v
- vertex whose presence in this edge is to be tested.
- true if this edge contains the specified vertex.
getSource
public Object getSource()
Returns the source vertex of this edge.
- the source vertex of this edge.
getTarget
public Object getTarget()
Returns the target vertex of this edge.
- 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.
- the weight of this element.
oppositeVertex
public Object oppositeVertex(Object v)
Returns the vertex opposite to the specified vertex.
v
- the vertex whose opposite is required.
- 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.