public abstract class CommunityMeasure extends SinkAdapter implements DynamicAlgorithm
Modifier and Type | Field and Description |
---|---|
protected HashMap<Object,HashSet<Node>> |
communities
All communities indexed by their marker value.
|
protected Graph |
graph
The graph for which the modularity will be computed.
|
protected boolean |
graphChanged
Set to false after
compute() . |
protected double |
M
Last value computed.
|
protected String |
marker
Name of the attribute marking the communities.
|
Constructor and Description |
---|
CommunityMeasure(String marker)
New measure algorithm with a given marker for communities.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assignNode(String nodeId,
Object newValue,
HashMap<Object,HashSet<Node>> assignment)
Put the node referred by nodeId to the community referred by newValue in
the assignment referred by assignment.
|
abstract void |
compute()
Run the algorithm.
|
void |
edgeAdded(String graphId,
long timeId,
String edgeId,
String fromNodeId,
String toNodeId,
boolean directed)
An edge was inserted in graph.
|
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.
|
double |
getLastComputedValue()
The last computed measure.
|
double |
getMeasure()
Compute the measure (if the graph changed since the last computation).
|
void |
graphCleared(String graphId,
long timeId)
The whole graph was cleared.
|
void |
init(Graph graph)
Initialization of the algorithm.
|
protected void |
initialize() |
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 |
nodeRemoved(String graphId,
long timeId,
String nodeId)
A node was removed from the graph.
|
void |
terminate()
Terminate the dynamic algorithm.
|
protected void |
unassignNode(String nodeId,
Object oldValue,
HashMap<Object,HashSet<Node>> assignment)
Remove the node referred by nodeId from the community referred by
oldValue in the assignment referred by assignment.
|
edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, nodeAttributeRemoved, stepBegins
protected HashMap<Object,HashSet<Node>> communities
protected boolean graphChanged
compute()
.protected double M
public CommunityMeasure(String marker)
marker
- name of the attribute marking the communities.public double getLastComputedValue()
public double getMeasure()
public void init(Graph graph)
Algorithm
Algorithm.compute()
method to initialize or reset the algorithm according
to the new given graph.public abstract void compute()
Algorithm
Algorithm.init(Graph)
method has to be called
before computing.compute
in interface Algorithm
Algorithm.init(Graph)
public void terminate()
DynamicAlgorithm
terminate
in interface DynamicAlgorithm
Algorithm.init(org.graphstream.graph.Graph)
protected void initialize()
public void nodeAdded(String graphId, long timeId, String nodeId)
ElementSink
nodeAdded
in interface ElementSink
nodeAdded
in class SinkAdapter
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
nodeRemoved
in class SinkAdapter
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
edgeAdded
in class SinkAdapter
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
edgeRemoved
in class SinkAdapter
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
graphCleared
in class SinkAdapter
graphId
- The graph cleared.public void nodeAttributeAdded(String graphId, long timeId, String nodeId, String attribute, Object value)
AttributeSink
nodeAttributeAdded
in interface AttributeSink
nodeAttributeAdded
in class SinkAdapter
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
nodeAttributeChanged
in class SinkAdapter
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.protected void assignNode(String nodeId, Object newValue, HashMap<Object,HashSet<Node>> assignment)
nodeId
- newValue
- assignment
- WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses