|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeersim.core.OverlayGraph
public class OverlayGraph
This class is an adaptor which makes a Linkable
protocol layer
look like a graph. It is useful because it allows the application of many
graph algorithms and graph topology initialization methods.
If the overlay network changes after creating this object, the changes
will be reflected. However, if the nodes are reshuffled (see
Network.shuffle()
), or if the node list changes (addition/removal),
then the behaviour becomes unspecified.
The indices of nodes are from 0 to Network.size()-1.
The fail state of nodes has an effect on the graph: all nodes are included
but edges are included only if both ends are up. This expresses the fact
that this graph is in fact defined by the "can communicate with" relation.
Field Summary | |
---|---|
int |
protocolID
The protocol ID that selects the Linkable protocol to convert to a graph. |
boolean |
wireDirected
Tells if the graph should be wired in an undirected way. |
Constructor Summary | |
---|---|
OverlayGraph(int protocolID)
|
|
OverlayGraph(int protocolID,
boolean wireDirected)
|
Method Summary | |
---|---|
boolean |
clearEdge(int i,
int j)
Not supported |
int |
degree(int i)
Returns number of neighbors that are up. |
boolean |
directed()
Returns always true |
int |
fullDegree(int i)
Returns number of neighbors that are either up or down. |
java.lang.Object |
getEdge(int i,
int j)
Returns null always |
java.util.Collection<java.lang.Integer> |
getNeighbours(int i)
Returns those neighbors that are up. |
java.lang.Object |
getNode(int i)
Returns Network.node[i] |
boolean |
isEdge(int i,
int j)
Returns true if there is a directed edge between node i and node j. |
boolean |
setEdge(int i,
int j)
Sets given edge. |
int |
size()
Returns Network.size() |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int protocolID
public final boolean wireDirected
directed()
returns true always, this affects only
method setEdge(int, int)
: if false, then the opposite edge is set too.
Constructor Detail |
---|
public OverlayGraph(int protocolID)
protocolID
- The protocol on which this adaptor is supposed
to operate.public OverlayGraph(int protocolID, boolean wireDirected)
protocolID
- The protocol on which this adaptor is supposed
to operate.wireDirected
- specifies if setEdge(int, int)
would wire the
opposite edge too.Method Detail |
---|
public boolean isEdge(int i, int j)
Graph
isEdge
in interface Graph
public java.util.Collection<java.lang.Integer> getNeighbours(int i)
getNeighbours
in interface Graph
public java.lang.Object getNode(int i)
Network.node[i]
getNode
in interface Graph
public java.lang.Object getEdge(int i, int j)
getEdge
in interface Graph
public int size()
Network.size()
size
in interface Graph
public boolean directed()
directed
in interface Graph
public boolean setEdge(int i, int j)
Conceptually one can think of it as a successful operation which is immediately overruled by the dynamics of the underlying overlay network. Let's not forget that this class is an adaptor only.
The behaviour of this method is affected by parameter wireDirected
.
If it is false, then the opposite edge is set too.
setEdge
in interface Graph
public boolean clearEdge(int i, int j)
clearEdge
in interface Graph
public int degree(int i)
degree
in interface Graph
public int fullDegree(int i)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |