public class Edge
extends java.lang.Object
implements java.io.Serializable, java.lang.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.
Modifier and Type | Field and Description |
---|---|
java.lang.Object |
info
Other information (maybe cost) associated with the edge
|
Constructor and Description |
---|
Edge(Edge e) |
Edge(java.lang.Object from,
java.lang.Object to,
java.lang.Object info) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object obj) |
java.lang.Object |
from()
Returns the "from" object.
|
boolean |
getDirected()
Returns true if the edge is directed or if we don't know our owner
|
java.lang.Object |
getFrom()
Returns the "from" object.
|
java.lang.Object |
getInfo() |
java.lang.Object |
getOtherNode(java.lang.Object node)
Returns the alternate to the provided node.
|
java.lang.Object |
getTo()
Returns the "to" object.
|
double |
getWeight()
Returns the weight of the edge.
|
int |
indexFrom() |
int |
indexTo() |
Network |
owner()
Returns the "owner" field.
|
void |
setInfo(java.lang.Object val) |
void |
setWeight(double weight)
Sets the weight of the edge to a java.lang.Double, discarding any previous weight or label.
|
java.lang.Object |
to()
Returns the "to" object.
|
java.lang.String |
toString() |
public java.lang.Object info
public Edge(Edge e)
public Edge(java.lang.Object from, java.lang.Object to, java.lang.Object info)
public java.lang.Object getFrom()
public java.lang.Object getTo()
public boolean getDirected()
public java.lang.Object from()
public java.lang.Object to()
public Network owner()
public int indexFrom()
public int indexTo()
public void setWeight(double weight)
public double getWeight()
public java.lang.Object getOtherNode(java.lang.Object node)
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."
public java.lang.Object getInfo()
public void setInfo(java.lang.Object val)
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable