public abstract class DecentralizedCommunityAlgorithm extends Object implements DynamicAlgorithm, Sink
Modifier and Type | Field and Description |
---|---|
protected Graph |
graph
The graph to apply the algorithm.
|
protected boolean |
graphChanged
Set to false after
compute() , unless static mode is set. |
protected String |
marker
Name of the attribute marking the communities.
|
protected String |
nonUniqueMarker |
protected Random |
rng
Random number generator used to shuffle the nodes.
|
protected boolean |
staticMode
Force algorithm to perform even if the graph is static.
|
Constructor and Description |
---|
DecentralizedCommunityAlgorithm()
Create a new distributed community detection algorithm, without attaching
it to a graph
|
DecentralizedCommunityAlgorithm(Graph graph)
Create a new distributed community detection algorithm, attached to the
specified graph
|
DecentralizedCommunityAlgorithm(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
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(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(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)
An edge was inserted in graph.
|
void |
edgeAttributeAdded(String graphId,
long timeId,
String edgeId,
String attribute,
Object value)
A edge attribute was added.
|
void |
edgeAttributeChanged(String graphId,
long timeId,
String edgeId,
String attribute,
Object oldValue,
Object newValue)
A edge attribute was changed.
|
void |
edgeAttributeRemoved(String graphId,
long timeId,
String edgeId,
String attribute)
A edge attribute was removed.
|
void |
edgeRemoved(String graphId,
long timeId,
String edgeId)
An edge of graph was removed.The nodes the edge connects may already have
been removed from the graph.
|
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)
A graph attribute was added.
|
void |
graphAttributeChanged(String graphId,
long timeId,
String attribute,
Object oldValue,
Object newValue)
A graph attribute was changed.
|
void |
graphAttributeRemoved(String graphId,
long timeId,
String attribute)
A graph attribute was removed.
|
void |
graphCleared(String graphId,
long timeId)
The whole graph was cleared.
|
void |
init(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(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)
A node was inserted in the given graph.
|
void |
nodeAttributeAdded(String graphId,
long timeId,
String nodeId,
String attribute,
Object value)
A node attribute was added.
|
void |
nodeAttributeChanged(String graphId,
long timeId,
String nodeId,
String attribute,
Object oldValue,
Object newValue)
A node attribute was changed.
|
void |
nodeAttributeRemoved(String graphId,
long timeId,
String nodeId,
String attribute)
A node attribute was removed.
|
void |
nodeRemoved(String graphId,
long timeId,
String nodeId)
A node was removed from the graph.
|
protected void |
originateCommunity(Node node)
Generate a new original community and attribute it to a node
|
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)
Since dynamic graphs are based on discrete event modifications, the
notion of step is defined to simulate elapsed time between events.
|
void |
terminate()
Terminate the dynamic algorithm.
|
protected void |
updateDisplayClass(Node node)
Update the display class of the node based on its current community.
|
protected String marker
protected String nonUniqueMarker
protected boolean graphChanged
compute()
, unless static mode is set.protected boolean staticMode
public DecentralizedCommunityAlgorithm()
public DecentralizedCommunityAlgorithm(Graph graph)
graph
- The graph on which the community assignment will be performedpublic DecentralizedCommunityAlgorithm(Graph graph, String marker)
graph
- The graph on which the community assignment will be performedmarker
- Marker string used to store the current community of a nodepublic void init(Graph graph, String marker)
graph
- marker
- public void init(Graph graph)
setRandom(Random)
function to use a
controlled random number generator with this algorithm.public void terminate()
DynamicAlgorithm
terminate
in interface DynamicAlgorithm
Algorithm.init(org.graphstream.graph.Graph)
public void staticMode()
public void setMarker(String marker)
marker
- public String getMarker()
public void setRandom(Random rng)
rng
- an initialized java.util.Random object.public Random getRandom()
public void compute()
compute
in interface Algorithm
Algorithm.init(Graph)
public abstract void computeNode(Node node)
node
- protected void originateCommunity(Node node)
node
- The node that will originate the new communityprotected void updateDisplayClass(Node node)
node
- public void attributeChanged(Element element, String attribute, Object oldValue, Object newValue)
public void nodeAdded(String graphId, long timeId, String nodeId)
ElementSink
nodeAdded
in interface ElementSink
graphId
- Identifier of the graph where the node was added.nodeId
- Identifier of the added node.public void nodeRemoved(String graphId, long timeId, String nodeId)
ElementSink
nodeRemoved
in interface ElementSink
graphId
- Identifier of the graph where the node will be removed.nodeId
- Identifier of the removed node.public void edgeAdded(String graphId, long timeId, String edgeId, String fromNodeId, String toNodeId, boolean directed)
ElementSink
edgeAdded
in interface ElementSink
graphId
- Identifier of the graph where the edge was added.edgeId
- Identifier of the added edge.fromNodeId
- Identifier of the first node of the edge.toNodeId
- Identifier of the second node of the edge.directed
- If true, the edge is directed.public void edgeRemoved(String graphId, long timeId, String edgeId)
ElementSink
edgeRemoved
in interface ElementSink
graphId
- The graph where the edge will be removed.edgeId
- The edge that will be removed.public void graphCleared(String graphId, long timeId)
ElementSink
graphCleared
in interface ElementSink
graphId
- The graph cleared.public void stepBegins(String graphId, long timeId, double time)
ElementSink
Since dynamic graphs are based on discrete event modifications, the notion of step is defined to simulate elapsed time between events. So a step is a event that occurs in the graph, it does not modify it but it gives a kind of timestamp that allow the tracking of the progress of the graph over the time.
This kind of event is useful for dynamic algorithms that listen to the dynamic graph and need to measure the time in the graph's evolution.
stepBegins
in interface ElementSink
graphId
- Identifier of the graph where the step starts.timeId
- A numerical value that may give a timestamp to track the
evolution of the graph over the time.public void graphAttributeAdded(String graphId, long timeId, String attribute, Object value)
AttributeSink
graphAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the attribute changed.attribute
- The attribute name.value
- The attribute new value.public void graphAttributeChanged(String graphId, long timeId, String attribute, Object oldValue, Object newValue)
AttributeSink
graphAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void graphAttributeRemoved(String graphId, long timeId, String attribute)
AttributeSink
graphAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.attribute
- The removed attribute name.public void nodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)
AttributeSink
nodeAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.nodeId
- Identifier of the node whose attribute changed.attribute
- The attribute name.value
- The attribute new value.public void nodeAttributeChanged(String graphId, long timeId, String nodeId, String attribute, Object oldValue, Object newValue)
AttributeSink
nodeAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.nodeId
- Identifier of the node whose attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void nodeAttributeRemoved(String graphId, long timeId, String nodeId, String attribute)
AttributeSink
nodeAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.nodeId
- Identifier of the node whose attribute was removed.attribute
- The removed attribute name.public void edgeAttributeAdded(String graphId, long timeId, String edgeId, String attribute, Object value)
AttributeSink
edgeAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.edgeId
- Identifier of the edge whose attribute changed.attribute
- The attribute name.value
- The attribute new value.public void edgeAttributeChanged(String graphId, long timeId, String edgeId, String attribute, Object oldValue, Object newValue)
AttributeSink
edgeAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.edgeId
- Identifier of the edge whose attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void edgeAttributeRemoved(String graphId, long timeId, String edgeId, String attribute)
AttributeSink
edgeAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.edgeId
- Identifier of the edge whose attribute was removed.attribute
- The removed attribute name.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses