|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.field.network.Edge
public class Edge
An Edge stores a relationship between two objects in a Network. Edges are directed: one object is a "from" object and one object is a "to" object. Edges also hold an "info" object, which is an arbitrary object that you specify on your own. An info object can be used to hold the edge weight, an edge label, or whatever you like. Edges are "semi-mutable": you can change the info object at any time, but you may not change the to or from objects once the Edge has been constructed.
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.
Field Summary | |
---|---|
java.lang.Object |
info
Other information (maybe cost) associated with the edge |
Constructor Summary | |
---|---|
Edge(Edge e)
|
|
Edge(java.lang.Object from,
java.lang.Object to,
java.lang.Object info)
|
Method Summary | |
---|---|
java.lang.Object |
from()
Returns the "from" object. |
java.lang.Object |
getOtherNode(java.lang.Object node)
Returns the alternate to the provided node. |
double |
getWeight()
Returns the weight of the edge. |
int |
indexFrom()
|
int |
indexTo()
|
Network |
owner()
Returns the "owner" field. |
java.lang.Object |
to()
Returns the "to" object. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.Object info
Constructor Detail |
---|
public Edge(Edge e)
public Edge(java.lang.Object from, java.lang.Object to, java.lang.Object info)
Method Detail |
---|
public java.lang.Object from()
public java.lang.Object to()
public Network owner()
public int indexFrom()
public int indexTo()
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.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |