|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectpeersim.graph.NeighbourListGraph
public class NeighbourListGraph
Implements a graph which uses the neighbour list representation. No multiple edges are allowed. The implementation also supports the growing of the graph. This is very useful when the number of nodes is not known in advance or when we construct a graph reading a file.
| Constructor Summary | |
|---|---|
NeighbourListGraph(boolean directed)
Constructs an empty graph. |
|
NeighbourListGraph(int size,
boolean directed)
Constructs a graph with a fixed size without edges. |
|
| Method Summary | |
|---|---|
int |
addNode(java.lang.Object o)
If the given object is not associated with a node yet, adds a new node. |
boolean |
clearEdge(int i,
int j)
Removes given edge, returns true if it existed before. |
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)
Returns null always. |
java.util.Collection<java.lang.Integer> |
getNeighbours(int i)
Returns a collection view to all outgoing edges from i. |
java.lang.Object |
getNode(int i)
If the graph was gradually grown using addNode(java.lang.Object), returns the
object associated with the node, otherwise null |
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, returns true if it did not exist before. |
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 NeighbourListGraph(boolean directed)
directed - if true the graph will be directed
public NeighbourListGraph(int size,
boolean directed)
addNode(java.lang.Object).
directed - if true the graph will be directed| Method Detail |
|---|
public int addNode(java.lang.Object o)
java.lang.NullPointerException - if the size was specified at construction time.
public boolean setEdge(int i,
int j)
Graph
setEdge in interface Graph
public boolean clearEdge(int i,
int j)
Graph
clearEdge in interface Graph
public boolean isEdge(int i,
int j)
Graph
isEdge in interface Graphpublic java.util.Collection<java.lang.Integer> getNeighbours(int i)
Graph
getNeighbours in interface Graphpublic java.lang.Object getNode(int i)
addNode(java.lang.Object), returns the
object associated with the node, otherwise null
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 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 | ||||||||