Class DecentralizedCommunityAlgorithm
java.lang.Object
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
Constructors Constructor Description DecentralizedCommunityAlgorithm()Create a new distributed community detection algorithm, without attaching it to a graphDecentralizedCommunityAlgorithm(org.graphstream.graph.Graph graph)Create a new distributed community detection algorithm, attached to the specified graphDecentralizedCommunityAlgorithm(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
Modifier and Type Method Description voidattributeChanged(org.graphstream.graph.Element element, String attribute, Object oldValue, Object newValue)voidcompute()Compute an iteration of the algorithm for all the nodes of the network.abstract voidcomputeNode(org.graphstream.graph.Node node)Perform computation of one iteration of the algorithm on a given node.StringdefaultMessage()voidedgeAdded(String graphId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)voidedgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)voidedgeAttributeChanged(String graphId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)voidedgeAttributeRemoved(String graphId, long timeId, String edgeId, String attribute)voidedgeRemoved(String graphId, long timeId, String edgeId)StringgetMarker()Get the marker used to store the community assignmentRandomgetRandom()Get the random number generator currently used for this algorithm.voidgraphAttributeAdded(String graphId, long timeId, String attribute, Object value)voidgraphAttributeChanged(String graphId, long timeId, String attribute, Object oldValue, Object newValue)voidgraphAttributeRemoved(String graphId, long timeId, String attribute)voidgraphCleared(String graphId, long timeId)voidinit(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.voidinit(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 attributevoidnodeAdded(String graphId, long timeId, String nodeId)voidnodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)voidnodeAttributeChanged(String graphId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)voidnodeAttributeRemoved(String graphId, long timeId, String nodeId, String attribute)voidnodeRemoved(String graphId, long timeId, String nodeId)voidsetMarker(String marker)Set the marker used to store the community assignment to the specified value.voidsetRandom(Random rng)Set the random number generator for this algorithm.voidstaticMode()Enable the static mode.voidstepBegins(String graphId, long timeId, double time)voidterminate()Terminate the dynamic algorithm.
-
Constructor Details
-
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
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 performedmarker- Marker string used to store the current community of a node
-
-
Method Details
-
init
Initialize the distributed community detection algorithm, attaching it to the specified graph, and using the specified marker to store the community attribute- Parameters:
graph- the graphmarker- marker string to store the community attribute
-
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 thesetRandom(Random)function to use a controlled random number generator with this algorithm. -
terminate
public void terminate()Description copied from interface:DynamicAlgorithmTerminate the dynamic algorithm.- Specified by:
terminatein interfaceDynamicAlgorithm- 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
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- marker string to store the community attribute
-
getMarker
Get the marker used to store the community assignment- Returns:
- the complete (i.e. prefixed) marker
-
setRandom
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
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:
computein interfaceAlgorithm- 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- node to compute
-
attributeChanged
-
nodeAdded
- Specified by:
nodeAddedin interfaceorg.graphstream.stream.ElementSink
-
nodeRemoved
- Specified by:
nodeRemovedin interfaceorg.graphstream.stream.ElementSink
-
edgeAdded
public void edgeAdded(String graphId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)- Specified by:
edgeAddedin interfaceorg.graphstream.stream.ElementSink
-
edgeRemoved
- Specified by:
edgeRemovedin interfaceorg.graphstream.stream.ElementSink
-
graphCleared
- Specified by:
graphClearedin interfaceorg.graphstream.stream.ElementSink
-
stepBegins
- Specified by:
stepBeginsin interfaceorg.graphstream.stream.ElementSink
-
graphAttributeAdded
- Specified by:
graphAttributeAddedin interfaceorg.graphstream.stream.AttributeSink
-
graphAttributeChanged
public void graphAttributeChanged(String graphId, long timeId, String attribute, Object oldValue, Object newValue)- Specified by:
graphAttributeChangedin interfaceorg.graphstream.stream.AttributeSink
-
graphAttributeRemoved
- Specified by:
graphAttributeRemovedin interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeAdded
public void nodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)- Specified by:
nodeAttributeAddedin interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeChanged
public void nodeAttributeChanged(String graphId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)- Specified by:
nodeAttributeChangedin interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeRemoved
- Specified by:
nodeAttributeRemovedin interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeAdded
public void edgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)- Specified by:
edgeAttributeAddedin interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeChanged
public void edgeAttributeChanged(String graphId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)- Specified by:
edgeAttributeChangedin interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeRemoved
- Specified by:
edgeAttributeRemovedin interfaceorg.graphstream.stream.AttributeSink
-
defaultMessage
-