Package org._3pq.jgrapht
Interface Edge
-
- All Superinterfaces:
java.lang.Cloneable
- All Known Implementing Classes:
DefaultEdge
,DirectedEdge
,DirectedWeightedEdge
,UndirectedEdge
,UndirectedWeightedEdge
public interface Edge extends java.lang.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.
- Since:
- Jul 14, 2003
- Author:
- Barak Naveh
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_EDGE_WEIGHT
The default weight for an edge.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.
-
-
-
Field Detail
-
DEFAULT_EDGE_WEIGHT
static final double DEFAULT_EDGE_WEIGHT
The default weight for an edge.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSource
java.lang.Object getSource()
Returns the source vertex of this edge.- Returns:
- the source vertex of this edge.
-
getTarget
java.lang.Object getTarget()
Returns the target vertex of this edge.- Returns:
- the target vertex of this edge.
-
setWeight
void setWeight(double weight)
Sets the weight of this edge. If this edge is unweighted anUnsupportedOperationException
is thrown.- Parameters:
weight
- new weight.- Throws:
java.lang.UnsupportedOperationException
- if this edge is unweighted.
-
getWeight
double getWeight()
Returns the weight of this edge. If this edge is unweighted the value1.0
is returned.- Returns:
- the weight of this element.
-
clone
java.lang.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
boolean containsVertex(java.lang.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.
-
oppositeVertex
java.lang.Object oppositeVertex(java.lang.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.
- Throws:
java.lang.IllegalArgumentException
- if v is neither the source nor the target vertices of this edge.java.lang.NullPointerException
- if v isnull
.
-
-