org.graphstream.algorithm.generator
Class BaseGenerator

java.lang.Object
  extended by org.graphstream.stream.SourceBase
      extended by org.graphstream.algorithm.generator.BaseGenerator
All Implemented Interfaces:
Generator, org.graphstream.stream.Source
Direct Known Subclasses:
BananaTreeGenerator, BarabasiAlbertGenerator, ChvatalGenerator, DorogovtsevMendesGenerator, FlowerSnarkGenerator, FullGenerator, GridGenerator, IncompleteGridGenerator, LCFGenerator, LifeGenerator, LobsterGenerator, PetersenGraphGenerator, PointsOfInterestGenerator, PreferentialAttachmentGenerator, RandomEuclideanGenerator, RandomFixedDegreeDynamicGraphGenerator, RandomGenerator, URLGenerator, WattsStrogatzGenerator

public abstract class BaseGenerator
extends org.graphstream.stream.SourceBase
implements Generator

Base graph 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).

Since:
2007

Nested Class Summary
 
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase
org.graphstream.stream.SourceBase.ElementType
 
Constructor Summary
BaseGenerator()
          New base graph generator.
BaseGenerator(boolean directed, boolean randomlyDirectedEdges)
          New base graph generator.
BaseGenerator(boolean directed, boolean randomlyDirectedEdges, String nodeAttribute, String edgeAttribute)
          New base graph generator.
 
Method Summary
 void addEdgeAttribute(String name)
          Add this attribute on all edges generated.
 void addEdgeLabels(boolean on)
          Allow to add label attributes on edges.
 void addNodeAttribute(String name)
          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(String name)
          Remove an automatic attribute for edges.
 void removeNodeAttribute(String name)
          Remove an automatic attribute for nodes.
 void setDirectedEdges(boolean directed, boolean randomly)
          Make each generated edge directed or not.
 void setEdgeAttributesRange(double low, double hi)
          If edge attributes are added automatically, choose in which range the values are choosed.
 void setNodeAttributesRange(double low, double hi)
          If node attributes are added automatically, choose in which range the values are choosed.
 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.
 
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.algorithm.generator.Generator
begin, nextEvents
 
Methods inherited from interface org.graphstream.stream.Source
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
 

Constructor Detail

BaseGenerator

public BaseGenerator()
New base graph generator. By default no attributes are added to nodes and edges, and edges are not directed.


BaseGenerator

public BaseGenerator(boolean directed,
                     boolean randomlyDirectedEdges)
New base graph generator. By default no attributes are added to nodes and edges. It is possible to make edge randomly directed.

Parameters:
directed - If true the edges are directed.
randomlyDirectedEdges - If true edge, are directed and the direction is chosen randomly.

BaseGenerator

public BaseGenerator(boolean directed,
                     boolean randomlyDirectedEdges,
                     String nodeAttribute,
                     String edgeAttribute)
New base graph generator.

Parameters:
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.
Method Detail

end

public void end()
End the graph generation by finalizing it. Once the 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.

Specified by:
end in interface Generator

setRandomSeed

public void setRandomSeed(long seed)
Set the random seed used for random number generation.

Parameters:
seed - The seed.

addNodeLabels

public void addNodeLabels(boolean on)
Allow to add label attributes on nodes. The label is the identifier of the node.

Parameters:
on - If true labels are added.

addEdgeLabels

public void addEdgeLabels(boolean on)
Allow to add label attributes on edges. The label is the identifier of the edge.

Parameters:
on - If true labels are added.

setDirectedEdges

public void setDirectedEdges(boolean directed,
                             boolean randomly)
Make each generated edge directed or not. If the new edge created are directed, the direction is chosen randomly.

Parameters:
directed - It true, edge will be directed.
randomly - If true, not only edges are directed, but the direction is chosen randomly.

addNodeAttribute

public void addNodeAttribute(String name)
Add this attribute on all nodes generated. This attribute will have a numerical value chosen in a range that is by default [0-1].

Parameters:
name - The attribute name.
See Also:
setNodeAttributesRange(double, double), removeNodeAttribute(String)

removeNodeAttribute

public void removeNodeAttribute(String name)
Remove an automatic attribute for nodes.

Parameters:
name - The attribute name.
See Also:
addNodeAttribute(String)

addEdgeAttribute

public void addEdgeAttribute(String name)
Add this attribute on all edges generated. This attribute will have a numerical value chosen in a range that is by default [0-1].

Parameters:
name - The attribute name.
See Also:
setEdgeAttributesRange(double, double), removeEdgeAttribute(String)

removeEdgeAttribute

public void removeEdgeAttribute(String name)
Remove an automatic attribute for edges.

Parameters:
name - The attribute name.
See Also:
addEdgeAttribute(String)

setNodeAttributesRange

public void setNodeAttributesRange(double low,
                                   double hi)
If node attributes are added automatically, choose in which range the values are choosed.

See Also:
addNodeAttribute(String)

setEdgeAttributesRange

public void setEdgeAttributesRange(double low,
                                   double hi)
If edge attributes are added automatically, choose in which range the values are choosed.

See Also:
addEdgeAttribute(String)

setUseInternalGraph

public void setUseInternalGraph(boolean on)
Enable or disable the use of an internal graph. If enable, nodes, edges and their attributes are stored in an internal graph. This is useful if the generator needs to remember informations like node id.

Parameters:
on - true if the internal graph has to be enable.

isUsingInternalGraph

public boolean isUsingInternalGraph()
Flag to know if an internal graph is in use.

Returns:
true if nodes and edges are stored in an internal graph.


Copyright © 2013. All Rights Reserved.