public abstract class BaseGenerator extends org.graphstream.stream.SourceBase implements Generator
This class is a base to implement generators. It it has facilities to generate edges or nodes, and provides services to add attributes on them and to choose if the edge is directed or not.
Indeed, 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, and in addition to ask that the direction be chosen randomly (by default, if edges must be oriented, the order given for the two nodes to connect is used).
Constructor and Description |
---|
BaseGenerator()
New base graph generator.
|
BaseGenerator(boolean directed,
boolean randomlyDirectedEdges)
New base graph generator.
|
BaseGenerator(boolean directed,
boolean randomlyDirectedEdges,
java.lang.String nodeAttribute,
java.lang.String edgeAttribute)
New base graph generator.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdgeAttribute(java.lang.String name)
Same as
addEdgeAttribute(String, Function) with default factory function. |
void |
addEdgeAttribute(java.lang.String name,
double min,
double max)
Same as
addEdgeAttribute(String, Function) with default factory function. |
void |
addEdgeAttribute(java.lang.String name,
java.util.function.Function<java.util.Random,?> factory)
Add this attribute on all edges generated.
|
void |
addEdgeLabels(boolean on)
Allow to add label attributes on edges.
|
void |
addNodeAttribute(java.lang.String name)
Same as
addNodeAttribute(String, Function) with default factory function. |
void |
addNodeAttribute(java.lang.String name,
double min,
double max)
Same as
addNodeAttribute(String, Function) with default factory function. |
void |
addNodeAttribute(java.lang.String name,
java.util.function.Function<java.util.Random,?> factory)
Add this attribute on all nodes generated.
|
void |
addNodeLabels(boolean on)
Allow to add label attributes on nodes.
|
void |
end()
End the graph generation by finalizing it.
|
boolean |
isUsingInternalGraph()
Flag to know if an internal graph is in use.
|
void |
removeEdgeAttribute(java.lang.String name)
Remove an automatic attribute for edges.
|
void |
removeNodeAttribute(java.lang.String name)
Remove an automatic attribute for nodes.
|
void |
setDirectedEdges(boolean directed,
boolean randomly)
Make each generated edge directed or not.
|
void |
setRandomSeed(long seed)
Set the random seed used for random number generation.
|
void |
setUseInternalGraph(boolean on)
Enable or disable the use of an internal graph.
|
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
begin, nextEvents
public BaseGenerator()
public BaseGenerator(boolean directed, boolean randomlyDirectedEdges)
directed
- If true the edges are directed.randomlyDirectedEdges
- If true edge, are directed and the direction is chosen
randomly.public BaseGenerator(boolean directed, boolean randomlyDirectedEdges, java.lang.String nodeAttribute, java.lang.String edgeAttribute)
directed
- If true the edges are directed.randomlyDirectedEdges
- It true, edges are directed and the direction is choosed
randomly.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.public void end()
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.public void setRandomSeed(long seed)
seed
- The seed.public void addNodeLabels(boolean on)
on
- If true labels are added.public void addEdgeLabels(boolean on)
on
- If true labels are added.public void setDirectedEdges(boolean directed, boolean randomly)
directed
- It true, edge will be directed.randomly
- If true, not only edges are directed, but the direction is
chosen randomly.public void addNodeAttribute(java.lang.String name, java.util.function.Function<java.util.Random,?> factory)
Random
object and which will return a random attribute value.name
- The attribute name.factory
- A factory that will create the attribute value from the random objectremoveNodeAttribute(String)
public void addNodeAttribute(java.lang.String name, double min, double max)
addNodeAttribute(String, Function)
with default factory function.
This attribute will have a numerical value chosen in a range that is by default [min-max].name
- The attribute name.min
- The minimum value for this attribute.max
- The maximum value for this attribute.addNodeAttribute(String, Function)
,
removeNodeAttribute(String)
public void addNodeAttribute(java.lang.String name)
addNodeAttribute(String, Function)
with default factory function.
This attribute will have a numerical value chosen in a range that is by default [0-1].name
- The attribute name.addNodeAttribute(String, Function)
,
addNodeAttribute(String, double, double)
,
removeNodeAttribute(String)
public void removeNodeAttribute(java.lang.String name)
name
- The attribute name.addNodeAttribute(String)
public void addEdgeAttribute(java.lang.String name, java.util.function.Function<java.util.Random,?> factory)
Random
object and which will return a random attribute value.name
- The attribute name.factory
- A factory that will create the attribute value from the random objectremoveEdgeAttribute(String)
public void addEdgeAttribute(java.lang.String name, double min, double max)
addEdgeAttribute(String, Function)
with default factory function.
This attribute will have a numerical value chosen in a range that is by default [min-max].name
- The attribute name.min
- The minimum value for this attribute.max
- The maximum value for this attribute.addEdgeAttribute(String, Function)
,
removeEdgeAttribute(String)
public void addEdgeAttribute(java.lang.String name)
addEdgeAttribute(String, Function)
with default factory function.
This attribute will have a numerical value chosen in a range that is by default [0-1].name
- The attribute name.addEdgeAttribute(String, Function)
,
addEdgeAttribute(String, double, double)
,
removeEdgeAttribute(String)
public void removeEdgeAttribute(java.lang.String name)
name
- The attribute name.addEdgeAttribute(String)
public void setUseInternalGraph(boolean on)
on
- true if the internal graph has to be enable.public boolean isUsingInternalGraph()