|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Graph.Edge
The Edge class for our Graph contains only the base minimum member variables. Environment specific semantics (such as RouterEdge or bandwidth etc) that are often attached to an edge are divorced from the this class and stored in a decorator class, EdgeConf (short for EdgeConfiguration). As such you can add/remove attributes to the Edge at run-time without having to change the Edge representation.
We use the decorator pattern as the relationship between a Edge and its configuration, EdgeConf. This pattern is described in Design Patterns: Elements of Reusable Object-Oriented Software by Gamma et al. ISBN#: 0-201-63361-2.
Like NodeIDs, unique edge ids are determined by using a static int and incrementing it each time a new edge is created. This is the default method. However, for improved lookup performance, we also provide alternative methods of computing EdgeIDs which embed the ids of the source and destination nodes of this edge in the EdgeID. As such given the source and destination node, one can compute the EdgeID in constant time. See Edge.computeID(..) and Edge.computeDirectedID(..) methods for more on how this is done.
NOTE: The direction of the edge can be either DIRECTED or UNDIRECTED. This allows for graphs that contain a hybrid of directed and undirected edges.
Field Summary | |
static Graph.EdgeIDComparator |
IDcomparator
|
Constructor Summary | |
Edge(Node src,
Node dst)
Class Constructor. |
Method Summary | |
static int |
computeDirectedID(int srcID,
int dstID)
|
static long |
computeDirectedLongID(int srcID,
int dstID)
Analagous to computeLongID above but computes ID for directed graph. |
static int |
computeID(int srcID,
int dstID)
Computes a unique EdgeID These IDs have the property that id(src,dest) = id(dest,src) and so should be used with undirected graphs only. |
static long |
computeLongID(int srcID,
int dstID)
Similar to computeID(src,dest) except returns a long id. |
float |
getBW()
|
int |
getColor()
|
int |
getDirection()
returns direction of this edge. |
Node |
getDst()
|
EdgeConf |
getEdgeConf()
|
static int |
getEdgeCount()
|
float |
getEuclideanDist()
compute the euclidean distance for this edge. |
int |
getID()
|
Node |
getSrc()
|
void |
setBW(float bw)
|
void |
setColor(int c)
|
void |
setDirection(int d)
Set the direction of this edge to either GraphConstants.DIRECTED or GraphConstants.UNDIRECTED |
void |
setDst(Node dst)
|
void |
setEdgeConf(EdgeConf e)
|
void |
setEuclideanDist(float d)
|
void |
setSrc(Node src)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static Graph.EdgeIDComparator IDcomparator
Constructor Detail |
public Edge(Node src, Node dst)
src
- The source node of this edgedst
- The destination node of this edgeMethod Detail |
public void setDirection(int d)
d
- the direction of the graph, one of the possible values specified in class GraphConstantspublic int getDirection()
public static int computeID(int srcID, int dstID)
srcID
- generally, the id of the source-nodedstID
- generally, the id of the dest-nodepublic static long computeLongID(int srcID, int dstID)
srcID
- the node-id of the srouce nodedstID
- the node-id of the dest nodepublic static int computeDirectedID(int srcID, int dstID)
public static long computeDirectedLongID(int srcID, int dstID)
srcID
- the source node iddstID
- the dest node idpublic float getEuclideanDist()
public Node getSrc()
public Node getDst()
public int getID()
public static int getEdgeCount()
public int getColor()
public EdgeConf getEdgeConf()
public float getBW()
public void setSrc(Node src)
public void setDst(Node dst)
public void setColor(int c)
public void setEdgeConf(EdgeConf e)
public void setBW(float bw)
public void setEuclideanDist(float d)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |