|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object peersim.graph.ConstUndirGraph
public class ConstUndirGraph
This class is an adaptor making any Graph an undirected graph
by making its edges bidirectional. The graph to be made undirected
is passed to the constructor. Only the reference is stored.
However, at construction time the incoming edges are stored
for each node, so if the graph
passed to the constructor changes over time then
methods getNeighbours(int)
and degree(int)
become inconsistent (but only those).
The upside of this inconvenience is that getNeighbours(int)
will have
constant time complexity.
UndirectedGraph
Field Summary | |
---|---|
protected Graph |
g
|
protected java.util.List<java.lang.Integer>[] |
in
|
Constructor Summary | |
---|---|
ConstUndirGraph(Graph g)
Initialization based on given graph. |
Method Summary | |
---|---|
boolean |
clearEdge(int i,
int j)
not supported |
int |
degree(int i)
Returns the degree of the given node. |
boolean |
directed()
Returns true if the graph is directed otherwise false. |
java.lang.Object |
getEdge(int i,
int j)
If there is an (i,j) edge, returns that, otherwise if there is a (j,i) edge, returns that, otherwise returns null. |
java.util.Collection<java.lang.Integer> |
getNeighbours(int i)
Uses sets as collection so does not support multiple edges now, even if the underlying directed graph does. |
java.lang.Object |
getNode(int i)
Returns the node from the underlying graph |
protected void |
initGraph()
Finds and stores incoming edges |
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)
not supported |
int |
size()
The number of nodes in the graph. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Graph g
protected final java.util.List<java.lang.Integer>[] in
Constructor Detail |
---|
public ConstUndirGraph(Graph g)
Method Detail |
---|
protected void initGraph()
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)
getNode
in interface Graph
public java.lang.Object getEdge(int i, int j)
getEdge
in interface Graph
public int size()
Graph
size
in interface Graph
public boolean directed()
Graph
directed
in interface Graph
public boolean setEdge(int i, int j)
setEdge
in interface Graph
public boolean clearEdge(int i, int j)
clearEdge
in interface Graph
public int degree(int i)
Graph
degree
in interface Graph
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |