|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnetkit.graph.Edge
public final class Edge
The Edge class represents an edge in the Graph object. It connects a source and destination Node with a given weight. Edges also have an EdgeType which specifies which kinds of Nodes can be connected by this Edge.
Graph
,
Node
,
EdgeType
,
Attributes
,
SchemaReader
Constructor Summary | |
---|---|
Edge(Edge e)
Copy constructor |
|
Edge(EdgeType edgeType,
Node source,
Node dest,
double weight)
The constructor requires an EdgeType, a source and destination Node and a weight. |
Method Summary | |
---|---|
void |
addWeight(double weight)
Increments the weight field of this Edge. |
int |
compareTo(Edge e)
Specifies a natural ordering for Edges; compare EdgeTypes first, then the source Node and finally the destination Node. |
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one. |
Node |
getDest()
Get the destination node of this object. |
EdgeType |
getEdgeType()
Get the edge type of this object. |
Node |
getSource()
Get the source node of this object. |
double |
getWeight()
Get the weight field of this object. |
int |
hashCode()
Returns a hash code value for this object. |
void |
setWeight(double weight)
Sets the weight field of this Edge. |
java.lang.String |
toString()
Returns a String representation for this object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Edge(EdgeType edgeType, Node source, Node dest, double weight)
edgeType
- an edge type describing the valid node types of
the source and destination nodes.source
- a node whose type must be valid for the EdgeType.dest
- a node whose type must be valid for the EdgeType.weight
- a double value representing the weight of this edge.
java.lang.RuntimeException
- if the source or dest Node's node type
is not valid for the supplied EdgeType.
java.lang.IllegalArgumentException
- if the supplied weight
increment is less than zero.public Edge(Edge e)
e
- an Edge to copy into a new object.Method Detail |
---|
public void addWeight(double weight)
weight
- the amount by which the weight is incremented.
java.lang.IllegalArgumentException
- if the supplied weight
increment is less than zero.public void setWeight(double weight)
weight
- the new weight of the edge.
java.lang.IllegalArgumentException
- if the supplied weight
is less than zero.public double getWeight()
public Node getSource()
public Node getDest()
public EdgeType getEdgeType()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the reference object with which to compare.
true
if this object is the same as the
argument; false
otherwise.public int compareTo(Edge e)
compareTo
in interface java.lang.Comparable<Edge>
e
- the Edge to compare this object to.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |