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.Objectclone()Creates and returns a shallow copy of this edge.booleancontainsVertex(java.lang.Object v)Returns true if this edge contains the specified vertex.java.lang.ObjectgetSource()Returns the source vertex of this edge.java.lang.ObjectgetTarget()Returns the target vertex of this edge.doublegetWeight()Returns the weight of this edge.java.lang.ObjectoppositeVertex(java.lang.Object v)Returns the vertex opposite to the specified vertex.voidsetWeight(double weight)Sets the weight of this edge.
-
-
-
Method Detail
-
getSource
public java.lang.Object getSource()
Description copied from interface:EdgeReturns the source vertex of this edge.- Specified by:
getSourcein interfaceEdge- Returns:
- the source vertex of this edge.
- See Also:
Edge.getSource()
-
getTarget
public java.lang.Object getTarget()
Description copied from interface:EdgeReturns the target vertex of this edge.- Specified by:
getTargetin interfaceEdge- Returns:
- the target vertex of this edge.
- See Also:
Edge.getTarget()
-
setWeight
public void setWeight(double weight)
Description copied from interface:EdgeSets the weight of this edge. If this edge is unweighted anUnsupportedOperationExceptionis thrown.- Specified by:
setWeightin interfaceEdge- Parameters:
weight- new weight.- See Also:
Edge.setWeight(double)
-
getWeight
public double getWeight()
Description copied from interface:EdgeReturns the weight of this edge. If this edge is unweighted the value1.0is returned.- Specified by:
getWeightin interfaceEdge- Returns:
- the weight of this element.
- See Also:
Edge.getWeight()
-
clone
public java.lang.Object clone()
Description copied from interface:EdgeCreates and returns a shallow copy of this edge. The vertices of this edge are not cloned.- Specified by:
clonein interfaceEdge- Overrides:
clonein 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:EdgeReturns 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:
containsVertexin 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:EdgeReturns the vertex opposite to the specified vertex.- Specified by:
oppositeVertexin interfaceEdge- Parameters:
v- the vertex whose opposite is required.- Returns:
- the vertex opposite to the specified vertex.
- See Also:
Edge.oppositeVertex(java.lang.Object)
-
-