org.graphstream.algorithm.community
Class DecentralizedCommunityAlgorithm

java.lang.Object
  extended by org.graphstream.algorithm.community.DecentralizedCommunityAlgorithm
All Implemented Interfaces:
Algorithm, DynamicAlgorithm, org.graphstream.stream.AttributeSink, org.graphstream.stream.ElementSink, org.graphstream.stream.Sink
Direct Known Subclasses:
EpidemicCommunityAlgorithm

public abstract class DecentralizedCommunityAlgorithm
extends Object
implements DynamicAlgorithm, org.graphstream.stream.Sink

Base class for all distributed community detection algorithm. They all implement the DynamicAlgorithm and Sink interfaces.

Author:
Guillaume-Jean Herbiet

Constructor Summary
DecentralizedCommunityAlgorithm()
          Create a new distributed community detection algorithm, without attaching it to a graph
DecentralizedCommunityAlgorithm(org.graphstream.graph.Graph graph)
          Create a new distributed community detection algorithm, attached to the specified graph
DecentralizedCommunityAlgorithm(org.graphstream.graph.Graph graph, String marker)
          Create a new distributed community detection algorithm, attached to the specified graph, and using the specified marker to store the community attribute
 
Method Summary
 void attributeChanged(org.graphstream.graph.Element element, String attribute, Object oldValue, Object newValue)
           
 void compute()
          Compute an iteration of the algorithm for all the nodes of the network.
abstract  void computeNode(org.graphstream.graph.Node node)
          Perform computation of one iteration of the algorithm on a given node.
 void edgeAdded(String graphId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)
           
 void edgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)
           
 void edgeAttributeChanged(String graphId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)
           
 void edgeAttributeRemoved(String graphId, long timeId, String edgeId, String attribute)
           
 void edgeRemoved(String graphId, long timeId, String edgeId)
           
 String getMarker()
          Get the marker used to store the community assignment
 Random getRandom()
          Get the random number generator currently used for this algorithm.
 void graphAttributeAdded(String graphId, long timeId, String attribute, Object value)
           
 void graphAttributeChanged(String graphId, long timeId, String attribute, Object oldValue, Object newValue)
           
 void graphAttributeRemoved(String graphId, long timeId, String attribute)
           
 void graphCleared(String graphId, long timeId)
           
 void init(org.graphstream.graph.Graph graph)
          Initialize the distributed community detection algorithm, attaching it to the specified graph, and using the default marker to store the community attribute.
 void init(org.graphstream.graph.Graph graph, String marker)
          Initialize the distributed community detection algorithm, attaching it to the specified graph, and using the specified marker to store the community attribute
 void nodeAdded(String graphId, long timeId, String nodeId)
           
 void nodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)
           
 void nodeAttributeChanged(String graphId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)
           
 void nodeAttributeRemoved(String graphId, long timeId, String nodeId, String attribute)
           
 void nodeRemoved(String graphId, long timeId, String nodeId)
           
 void setMarker(String marker)
          Set the marker used to store the community assignment to the specified value.
 void setRandom(Random rng)
          Set the random number generator for this algorithm.
 void staticMode()
          Enable the static mode.
 void stepBegins(String graphId, long timeId, double time)
           
 void terminate()
          Terminate the dynamic algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecentralizedCommunityAlgorithm

public DecentralizedCommunityAlgorithm()
Create a new distributed community detection algorithm, without attaching it to a graph


DecentralizedCommunityAlgorithm

public DecentralizedCommunityAlgorithm(org.graphstream.graph.Graph graph)
Create a new distributed community detection algorithm, attached to the specified graph

Parameters:
graph - The graph on which the community assignment will be performed

DecentralizedCommunityAlgorithm

public DecentralizedCommunityAlgorithm(org.graphstream.graph.Graph graph,
                                       String marker)
Create a new distributed community detection algorithm, attached to the specified graph, and using the specified marker to store the community attribute

Parameters:
graph - The graph on which the community assignment will be performed
marker - Marker string used to store the current community of a node
Method Detail

init

public void init(org.graphstream.graph.Graph graph,
                 String marker)
Initialize the distributed community detection algorithm, attaching it to the specified graph, and using the specified marker to store the community attribute

Parameters:
graph -
marker -

init

public void init(org.graphstream.graph.Graph graph)
Initialize the distributed community detection algorithm, attaching it to the specified graph, and using the default marker to store the community attribute. By default an uncontrolled random number generator will be used. For sake of reproducibility, use the setRandom(Random) function to use a controlled random number generator with this algorithm.

Specified by:
init in interface Algorithm
Parameters:
graph -

terminate

public void terminate()
Description copied from interface: DynamicAlgorithm
Terminate the dynamic algorithm.

Specified by:
terminate in interface DynamicAlgorithm
See Also:
Algorithm.init(org.graphstream.graph.Graph)

staticMode

public void staticMode()
Enable the static mode. In this mode, algorithm will perform even if the graph hasn't changed (useful for static graphs).


setMarker

public void setMarker(String marker)
Set the marker used to store the community assignment to the specified value. The given value will be prefixed by [AlgorithmClass].[InstanceNumber] to make this unique for each instance of the algorithm.

Parameters:
marker -

getMarker

public String getMarker()
Get the marker used to store the community assignment

Returns:
the complete (i.e. prefixed) marker

setRandom

public void setRandom(Random rng)
Set the random number generator for this algorithm. For sake of reproducibility, the given random number generator shall be initiated with a controlled seed.

Parameters:
rng - an initialized java.util.Random object.

getRandom

public Random getRandom()
Get the random number generator currently used for this algorithm.

Returns:
the current random number generator.

compute

public void compute()
Compute an iteration of the algorithm for all the nodes of the network.

Specified by:
compute in interface Algorithm
See Also:
Algorithm.init(Graph)
Computational Complexity :
N times the complexity of the computeNode() function, where N is the number of nodes in the network.

computeNode

public abstract void computeNode(org.graphstream.graph.Node node)
Perform computation of one iteration of the algorithm on a given node.

Parameters:
node -

attributeChanged

public void attributeChanged(org.graphstream.graph.Element element,
                             String attribute,
                             Object oldValue,
                             Object newValue)

nodeAdded

public void nodeAdded(String graphId,
                      long timeId,
                      String nodeId)
Specified by:
nodeAdded in interface org.graphstream.stream.ElementSink

nodeRemoved

public void nodeRemoved(String graphId,
                        long timeId,
                        String nodeId)
Specified by:
nodeRemoved in interface org.graphstream.stream.ElementSink

edgeAdded

public void edgeAdded(String graphId,
                      long timeId,
                      String edgeId,
                      String fromNodeId,
                      String toNodeId,
                      boolean directed)
Specified by:
edgeAdded in interface org.graphstream.stream.ElementSink

edgeRemoved

public void edgeRemoved(String graphId,
                        long timeId,
                        String edgeId)
Specified by:
edgeRemoved in interface org.graphstream.stream.ElementSink

graphCleared

public void graphCleared(String graphId,
                         long timeId)
Specified by:
graphCleared in interface org.graphstream.stream.ElementSink

stepBegins

public void stepBegins(String graphId,
                       long timeId,
                       double time)
Specified by:
stepBegins in interface org.graphstream.stream.ElementSink

graphAttributeAdded

public void graphAttributeAdded(String graphId,
                                long timeId,
                                String attribute,
                                Object value)
Specified by:
graphAttributeAdded in interface org.graphstream.stream.AttributeSink

graphAttributeChanged

public void graphAttributeChanged(String graphId,
                                  long timeId,
                                  String attribute,
                                  Object oldValue,
                                  Object newValue)
Specified by:
graphAttributeChanged in interface org.graphstream.stream.AttributeSink

graphAttributeRemoved

public void graphAttributeRemoved(String graphId,
                                  long timeId,
                                  String attribute)
Specified by:
graphAttributeRemoved in interface org.graphstream.stream.AttributeSink

nodeAttributeAdded

public void nodeAttributeAdded(String graphId,
                               long timeId,
                               String nodeId,
                               String attribute,
                               Object value)
Specified by:
nodeAttributeAdded in interface org.graphstream.stream.AttributeSink

nodeAttributeChanged

public void nodeAttributeChanged(String graphId,
                                 long timeId,
                                 String nodeId,
                                 String attribute,
                                 Object oldValue,
                                 Object newValue)
Specified by:
nodeAttributeChanged in interface org.graphstream.stream.AttributeSink

nodeAttributeRemoved

public void nodeAttributeRemoved(String graphId,
                                 long timeId,
                                 String nodeId,
                                 String attribute)
Specified by:
nodeAttributeRemoved in interface org.graphstream.stream.AttributeSink

edgeAttributeAdded

public void edgeAttributeAdded(String graphId,
                               long timeId,
                               String edgeId,
                               String attribute,
                               Object value)
Specified by:
edgeAttributeAdded in interface org.graphstream.stream.AttributeSink

edgeAttributeChanged

public void edgeAttributeChanged(String graphId,
                                 long timeId,
                                 String edgeId,
                                 String attribute,
                                 Object oldValue,
                                 Object newValue)
Specified by:
edgeAttributeChanged in interface org.graphstream.stream.AttributeSink

edgeAttributeRemoved

public void edgeAttributeRemoved(String graphId,
                                 long timeId,
                                 String edgeId,
                                 String attribute)
Specified by:
edgeAttributeRemoved in interface org.graphstream.stream.AttributeSink


Copyright © 2011. All Rights Reserved.