Class ChainGenerator
- All Implemented Interfaces:
Generator
,org.graphstream.stream.Source
public class ChainGenerator extends BaseGenerator
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
-
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.algorithm.generator.BaseGenerator
addEdgeAttribute, addEdgeAttribute, addEdgeAttribute, addEdgeLabels, addNodeAttribute, addNodeAttribute, addNodeAttribute, addNodeLabels, 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
-
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
-
begin
public void begin()Add an initial node.- See Also:
Generator.begin()
-
nextEvents
public boolean nextEvents()Add a new node (link) in the chain.- Returns:
- true while there are elements to add to the graph.
- See Also:
Generator.nextEvents()
-
end
public void end()If the graph is set to have a loop back edge, this method will add it.- Specified by:
end
in interfaceGenerator
- Overrides:
end
in classBaseGenerator
- See Also:
Generator.end()
-