|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.graphstream.stream.SourceBase
org.graphstream.algorithm.generator.BaseGenerator
org.graphstream.algorithm.generator.WattsStrogatzGenerator
public class WattsStrogatzGenerator
A generator following the small-world model of Watts and Strogatz.
This generator creates small-world graphs of arbitrary size.
This model generates a ring of n nodes where each node is connected to its k nearest neighbours in the ring (k/2 on each side, which means k must be even). Then it process each node of the ring in order following the ring, and "rewiring" each of their edges toward the not yet processed nodes with randomly chosen nodes with a probability beta.
You must provide values for n, k and beta at construction time. You must ensure that k is event, that n >> k >> log(n) >> 1. Furthermore, beta being a probability it must be between 0 and 1.
By default, the generator will produce a placement for nodes using the ``xyz`` attribute.
This generator will produce the ring of nodes once begin()
has been
called. Then calling nextEvents()
will rewire one node at a time
return true until each node is processed, in which case it returns false.
You must then call end()
.
Graph graph = new SingleGraph("This is a small world!"); Generator gen = new WattsStrogatzGenerator(20, 2, 0.5); gen.addSink(graph); gen.begin(); while(gen.nextEvents()) {} gen.end(); graph.display(false); // Node position is provided.
This generator is based on the Watts-Strogatz model.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase |
---|
org.graphstream.stream.SourceBase.ElementType |
Constructor Summary | |
---|---|
WattsStrogatzGenerator(int n,
int k,
double beta)
New Watts-Strogatz generator. |
Method Summary | |
---|---|
void |
begin()
Begin the graph generation. |
void |
end()
End the graph generation by finalizing it. |
boolean |
nextEvents()
Perform the next step in generating the graph. |
Methods inherited from class org.graphstream.algorithm.generator.BaseGenerator |
---|
addEdgeAttribute, addEdgeLabels, addNodeAttribute, addNodeLabels, isUsingInternalGraph, removeEdgeAttribute, removeNodeAttribute, setDirectedEdges, setEdgeAttributesRange, setNodeAttributesRange, setRandomSeed, setUseInternalGraph |
Methods inherited from class org.graphstream.stream.SourceBase |
---|
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeRemoved, sendEdgeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.graphstream.stream.Source |
---|
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink |
Constructor Detail |
---|
public WattsStrogatzGenerator(int n, int k, double beta)
n
- The number of nodes to generate.k
- The base degree of each node.beta
- Probability to "rewire" an edge.Method Detail |
---|
public void begin()
Generator
Generator.nextEvents()
method to add elements to the graph.
public boolean nextEvents()
Generator
public void end()
BaseGenerator
Generator.nextEvents()
method returned false (or even if you stop before), this method must be
called to finish the graph.
In addition, BaseGenerator adds a "clear" operations that removes all the
kept edges and nodes identifiers and the associated data.
end
in interface Generator
end
in class BaseGenerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |