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 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.String
defaultMessage()
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 assignmentRandom
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 attributevoid
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.
-
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:DynamicAlgorithm
Terminate the dynamic algorithm.- Specified by:
terminate
in 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:
compute
in 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:
nodeAdded
in interfaceorg.graphstream.stream.ElementSink
-
nodeRemoved
- Specified by:
nodeRemoved
in interfaceorg.graphstream.stream.ElementSink
-
edgeAdded
public void edgeAdded(String graphId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)- Specified by:
edgeAdded
in interfaceorg.graphstream.stream.ElementSink
-
edgeRemoved
- Specified by:
edgeRemoved
in interfaceorg.graphstream.stream.ElementSink
-
graphCleared
- Specified by:
graphCleared
in interfaceorg.graphstream.stream.ElementSink
-
stepBegins
- Specified by:
stepBegins
in interfaceorg.graphstream.stream.ElementSink
-
graphAttributeAdded
- Specified by:
graphAttributeAdded
in interfaceorg.graphstream.stream.AttributeSink
-
graphAttributeChanged
public void graphAttributeChanged(String graphId, long timeId, String attribute, Object oldValue, Object newValue)- Specified by:
graphAttributeChanged
in interfaceorg.graphstream.stream.AttributeSink
-
graphAttributeRemoved
- Specified by:
graphAttributeRemoved
in interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeAdded
public void nodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)- Specified by:
nodeAttributeAdded
in interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeChanged
public void nodeAttributeChanged(String graphId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)- Specified by:
nodeAttributeChanged
in interfaceorg.graphstream.stream.AttributeSink
-
nodeAttributeRemoved
- Specified by:
nodeAttributeRemoved
in interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeAdded
public void edgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)- Specified by:
edgeAttributeAdded
in interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeChanged
public void edgeAttributeChanged(String graphId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)- Specified by:
edgeAttributeChanged
in interfaceorg.graphstream.stream.AttributeSink
-
edgeAttributeRemoved
- Specified by:
edgeAttributeRemoved
in interfaceorg.graphstream.stream.AttributeSink
-
defaultMessage
-