use of org.gephi.statistics.plugin.ClusteringCoefficient in project gephi by gephi.
the class DynamicClusteringCoefficient method loop.
@Override
public void loop(GraphView window, Interval interval) {
Graph graph;
if (isDirected) {
graph = graphModel.getDirectedGraph(window);
} else {
graph = graphModel.getUndirectedGraph(window);
}
TimeRepresentation tr = graphModel.getConfiguration().getTimeRepresentation();
graph.readLock();
try {
clusteringCoefficientStat = new ClusteringCoefficient();
clusteringCoefficientStat.setDirected(isDirected);
clusteringCoefficientStat.triangles(graph);
//Columns
if (!averageOnly) {
double[] coefficients = clusteringCoefficientStat.getCoefficientReuslts();
int i = 0;
for (Node n : graph.getNodes()) {
double coef = coefficients[i++];
switch(tr) {
case INTERVAL:
n.setAttribute(dynamicCoefficientColumn, coef, new Interval(interval.getLow(), interval.getLow() + tick));
break;
case TIMESTAMP:
n.setAttribute(dynamicCoefficientColumn, coef, interval.getLow());
n.setAttribute(dynamicCoefficientColumn, coef, interval.getHigh());
break;
}
if (cancel) {
break;
}
}
}
} finally {
graph.readUnlockAll();
}
//Average
double avg = clusteringCoefficientStat.getAverageClusteringCoefficient();
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVG_CLUSTERING_COEFFICIENT, avg, interval.getLow());
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVG_CLUSTERING_COEFFICIENT, avg, interval.getHigh());
averages.put(interval.getLow(), avg);
averages.put(interval.getHigh(), avg);
}
Aggregations