Class ChainGenerator

java.lang.Object
org.graphstream.stream.SourceBase
org.graphstream.algorithm.generator.BaseGenerator
org.graphstream.algorithm.generator.ChainGenerator
All Implemented Interfaces:
Generator, org.graphstream.stream.Source

public class ChainGenerator
extends BaseGenerator
Generator for a chain graph of any size.

This generator creates a chain graph (much like a linked-list). By default, the graph is directed and doubly linked (much like a doubly linked-list). That is, each node has an edge to the next node in the chain, and one going back to the previous (except for the first and last nodes). A loop back edge can be added such that the last node in the chain has an edge directly back to the starting node.

Usage

Calling begin() will add an initial node with no edges. Each call to nextEvents() will add a new node, connected to the previous node, in a chain. If the graph is directed and doubly linked, each call will result in the addition of two new edges, otherwise just a single edge is added. Thus, if the graph is undirected, then the doubly linked parameter is ignored, and only single edges are created between nodes.

If you are displaying the graph, directed and doubly-linked chain graphs are best viewed with the cubic-curve edge shape CSS property, though it will require the use of the gs-ui renderer to work.

Since:
2014
  • Nested Class Summary

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

    org.graphstream.stream.SourceBase.ElementType
  • Constructor Summary

    Constructors 
    Constructor Description
    ChainGenerator()
    New chain generator.
    ChainGenerator​(boolean directed, boolean doublyLinked, boolean loopBack)
    New chain generator.
  • Method Summary

    Modifier and Type Method Description
    void begin()
    Add an initial node.
    void end()
    If the graph is set to have a loop back edge, this method will add it.
    boolean nextEvents()
    Add a new node (link) in the chain.

    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

    • ChainGenerator

      public ChainGenerator()
      New chain generator. By default edges are directed, nodes doubly linked, and there is no loop back edge.
    • ChainGenerator

      public ChainGenerator​(boolean directed, boolean doublyLinked, boolean loopBack)
      New chain generator.
      Parameters:
      directed - Should the edges be directed?
      doublyLinked - Should the nodes be doubly linked?
      loopBack - Should the graph have a loop back edge?
  • Method Details