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

    Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase

    org.graphstream.stream.SourceBase.ElementType
  • 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 node
    boolean nextEvents()
    Grows the hypercube dimension by doubling all the existing nodes and adding the corresponding edges.

    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

    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 Details

  • 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()