Class Edge
- All Implemented Interfaces:
Serializable
,Comparable
An Edge may be added to at most one Network. You must remove it from that field before you can add it to a new Network. The Edge's field is known as its owner.
Explicitly stating weights. The getWeight() function returns a plausible weight for the edge. If your "info" object is a Number or a MutableDouble, or is sim.util.Valuable, then the weight of the edge is the doubleValue() of your object. Else the weight of the edge is a default of 1.0.
Edges are java.lang.Comparable as long as their 'info' elements are Numbers or are sim.util.Valuable. In this case, the comparison is such that lower values sort first.
Though Edges are comparable, they hash by reference. Edges are always considered unique.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
from()
Returns the "from" object.boolean
Returns true if the edge is directed or if we don't know our ownergetFrom()
Returns the "from" object.getInfo()
getOtherNode
(Object node) Returns the alternate to the provided node.getTo()
Returns the "to" object.double
Returns the weight of the edge.int
int
indexTo()
owner()
Returns the "owner" field.void
void
setWeight
(double weight) Sets the weight of the edge to a java.lang.Double, discarding any previous weight or label.to()
Returns the "to" object.toString()
-
Field Details
-
info
Other information (maybe cost) associated with the edge
-
-
Constructor Details
-
Edge
-
Edge
-
-
Method Details
-
getFrom
Returns the "from" object. -
getTo
Returns the "to" object. -
getDirected
public boolean getDirected()Returns true if the edge is directed or if we don't know our owner -
from
Returns the "from" object. -
to
Returns the "to" object. -
owner
Returns the "owner" field. -
indexFrom
public int indexFrom() -
indexTo
public int indexTo() -
setWeight
public void setWeight(double weight) Sets the weight of the edge to a java.lang.Double, discarding any previous weight or label. -
getWeight
public double getWeight()Returns the weight of the edge. The default version of the function returns the value of the info object if it is a subclass of Number (including MutableDouble) or is Valuable, else returns 1.0. -
getOtherNode
Returns the alternate to the provided node. Specifically: if node == getFrom(), then getTo() is returned; else getFrom() is returned. Note that if node != getFrom() AND node != getTo(), then getFrom() is still returned.This method is useful for various algorithms which operate both on undirected and on directed graphs; rather than knowing if you're "to" or "from", you can just "get the node on the other side of the edge."
-
getInfo
-
setInfo
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable
-