Class HypercubeGenerator
java.lang.Object
org.graphstream.stream.SourceBase
org.graphstream.algorithm.generator.BaseGenerator
org.graphstream.algorithm.generator.HypercubeGenerator
- All Implemented Interfaces:
Generator
,org.graphstream.stream.Source
public class HypercubeGenerator extends BaseGenerator
Generates a hypercube of dimension equal to the number of calls to
nextEvents()
.
After d calls to nextEvents()
one obtains a graph with 2^d nodes. Nodes i and j are connected
if and only if their binary representations differ by exactly one bit.
Example
Graph graph = new SingleGraph("hypercube"); Generator gen = new HypercubeGenerator(); gen.addSink(graph); gen.begin(); for (dim = 1; dim <= 4; dim++) gen.nextEvents(); gen.end();
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description HypercubeGenerator()
Creates a hypercube generator -
Method Summary
Modifier and Type Method Description void
begin()
Creates a hypercube of dimension 0, that is, a single nodeboolean
nextEvents()
Grows the hypercube dimension by doubling all the existing nodes and adding the corresponding edges.Methods inherited from class org.graphstream.algorithm.generator.BaseGenerator
addEdgeAttribute, addEdgeAttribute, addEdgeAttribute, addEdgeLabels, addNodeAttribute, addNodeAttribute, addNodeAttribute, addNodeLabels, end, isUsingInternalGraph, removeEdgeAttribute, removeNodeAttribute, setDirectedEdges, 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, sendEdgeAttributeAdded, sendEdgeAttributeAdded, sendEdgeAttributeChanged, sendEdgeAttributeChanged, sendEdgeAttributeRemoved, sendEdgeAttributeRemoved, sendEdgeRemoved, sendEdgeRemoved, sendGraphAttributeAdded, sendGraphAttributeAdded, sendGraphAttributeChanged, sendGraphAttributeChanged, sendGraphAttributeRemoved, sendGraphAttributeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeAttributeAdded, sendNodeAttributeAdded, sendNodeAttributeChanged, sendNodeAttributeChanged, sendNodeAttributeRemoved, sendNodeAttributeRemoved, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins
-
Constructor Details
-
HypercubeGenerator
public HypercubeGenerator()Creates a hypercube generator
-
-
Method Details
-
begin
public void begin()Creates a hypercube of dimension 0, that is, a single node- See Also:
Generator.begin()
-
nextEvents
public boolean nextEvents()Grows the hypercube dimension by doubling all the existing nodes and adding the corresponding edges.- Returns:
- true while there are elements to add to the graph.
- See Also:
Generator.nextEvents()
-