Package org._3pq.jgrapht.edge
Class DefaultEdge
- java.lang.Object
-
- org._3pq.jgrapht.edge.DefaultEdge
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Edge
- Direct Known Subclasses:
DirectedEdge
,UndirectedEdge
public class DefaultEdge extends java.lang.Object implements Edge, java.lang.Cloneable, java.io.Serializable
A skeletal implementation of the Edge interface, to minimize the effort required to implement the interface.- Since:
- Jul 14, 2003
- Author:
- Barak Naveh
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org._3pq.jgrapht.Edge
DEFAULT_EDGE_WEIGHT
-
-
Constructor Summary
Constructors Constructor Description DefaultEdge(java.lang.Object sourceVertex, java.lang.Object targetVertex)
Constructor for DefaultEdge.
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Method Detail
-
getSource
public java.lang.Object getSource()
Description copied from interface:Edge
Returns the source vertex of this edge.- Specified by:
getSource
in interfaceEdge
- Returns:
- the source vertex of this 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 interfaceEdge
- Returns:
- the target vertex of this 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 anUnsupportedOperationException
is thrown.- Specified by:
setWeight
in interfaceEdge
- Parameters:
weight
- new weight.- 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 value1.0
is returned.- Specified by:
getWeight
in interfaceEdge
- Returns:
- the weight of this element.
- 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 interfaceEdge
- Overrides:
clone
in classjava.lang.Object
- Returns:
- a shallow copy of this edge.
- 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 interfaceEdge
- Parameters:
v
- vertex whose presence in this edge is to be tested.- Returns:
- true if this edge contains the specified vertex.
- 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 interfaceEdge
- Parameters:
v
- the vertex whose opposite is required.- Returns:
- the vertex opposite to the specified vertex.
- See Also:
Edge.oppositeVertex(java.lang.Object)
-
-