|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectpeersim.graph.UndirectedGraph
public class UndirectedGraph
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 so
if the directed graph changes later, the undirected version will
follow that change. However, getNeighbours(int) has O(n) time complexity
(in other words, too slow for large graphs).
ConstUndirGraph| Constructor Summary | |
|---|---|
UndirectedGraph(Graph g)
|
|
| 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 object associated with the index. |
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 |
| Constructor Detail |
|---|
public UndirectedGraph(Graph g)
| Method Detail |
|---|
public boolean isEdge(int i,
int j)
Graph
isEdge in interface Graphpublic java.util.Collection<java.lang.Integer> getNeighbours(int i)
getNeighbours in interface Graphpublic java.lang.Object getNode(int i)
Graph
getNode in interface Graph
public java.lang.Object getEdge(int i,
int j)
getEdge in interface Graphpublic int size()
Graph
size in interface Graphpublic 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 Graphpublic 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 | ||||||||