|
||||||||||
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.RandomGenerator
public class RandomGenerator
Random graph generator.
Generate a random graph of any size.
This generator creates random graphs of any size. Calling begin()
put one unique node in the graph, then nextEvents()
will add a new
node each time it is called and connect this node randomly to others.
The generator tries to generate nodes with random connections, with each node having in average a given degree. The law in a Poisson law, however, the way this generator works, adding node after node, perturbs this process. We should first allocate all the needed nodes, then create edges. However, we create nodes at the same rate as edges. The more nodes are added the more the degree distribution curve is shifted toward the right.
This generator has the ability to add randomly chosen numerical values on arbitrary attributes on edges or nodes of the graph, and to randomly choose a direction for edges.
A list of attributes can be given for nodes and edges. In this case each new node or edge added will have this attribute and the value will be a randomly chosen number. The range in which these numbers are chosen can be specified.
By default, edges are not oriented. It is possible to ask orientation, in which case the direction is chosen randomly.
At each call to nextEvents()
at max k operations are run with
k the average degree.
Graph graph = new SingleGraph("Random"); Generator gen = new RandomGenerator(); gen.addSinkg(graph); gen.begin(); for(int i=0; i<100; i++) gen.nextEvents(); gen.end(); graph.display();
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase |
---|
org.graphstream.stream.SourceBase.ElementType |
Constructor Summary | |
---|---|
RandomGenerator()
New full graph generator with default attributes. |
|
RandomGenerator(int averageDegree)
New full graph generator. |
|
RandomGenerator(int averageDegree,
boolean directed,
boolean randomlyDirectedEdges)
New full graph generator. |
|
RandomGenerator(int averageDegree,
boolean directed,
boolean randomlyDirectedEdges,
String nodeAttribute,
String edgeAttribute)
New random graph generator. |
Method Summary | |
---|---|
void |
begin()
Start the generator. |
void |
end()
End the graph generation by finalizing it. |
boolean |
nextEvents()
Step the generator. |
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 RandomGenerator()
public RandomGenerator(int averageDegree)
averageDegree
- The average degree of nodes.public RandomGenerator(int averageDegree, boolean directed, boolean randomlyDirectedEdges)
averageDegree
- The average degree of nodes.directed
- Are edges directed?.randomlyDirectedEdges
- randomly direct generated edges.public RandomGenerator(int averageDegree, boolean directed, boolean randomlyDirectedEdges, String nodeAttribute, String edgeAttribute)
averageDegree
- The average degree of nodes.directed
- Are edges directed?.randomlyDirectedEdges
- randomly direct generated edges.nodeAttribute
- put an attribute by that name on each node with a random
numeric value.edgeAttribute
- put an attribute by that name on each edge with a random
numeric value.Method Detail |
---|
public void begin()
Generator.begin()
public boolean nextEvents()
Generator.nextEvents()
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 |