Skip to content

Commit

Permalink
Merge pull request #626 from brycethomas/master
Browse files Browse the repository at this point in the history
Fixes calculation of clustering coefficient on graph (Issue #625)
  • Loading branch information
sheymann committed May 20, 2012
2 parents 77a0699 + 16c7da7 commit 00d4318
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -458,8 +458,10 @@ public void triangles(HierarchicalGraph hgraph) {
//Results and average
avgClusteringCoeff = 0;
totalTriangles = 0;
int numNodesDegreeGreaterThanOne = 0;
for (int v = 0; v < N; v++) {
if (network[v].length() > 1) {
numNodesDegreeGreaterThanOne++;
double cc = triangles[v];
totalTriangles += triangles[v];
cc /= (network[v].length() * (network[v].length() - 1));
Expand All @@ -477,7 +479,7 @@ public void triangles(HierarchicalGraph hgraph) {
}
}
totalTriangles /= 3;
avgClusteringCoeff /= N;
avgClusteringCoeff /= numNodesDegreeGreaterThanOne;

hgraph.readUnlock();
}
Expand Down Expand Up @@ -524,8 +526,6 @@ private void bruteForce(HierarchicalGraph hgraph, AttributeModel attributeModel)
}
nodeCC /= 2.0;



if (neighborhood > 1) {
float cc = nodeCC / (.5f * neighborhood * (neighborhood - 1));
if (isDirected) {
Expand Down

0 comments on commit 00d4318

Please sign in to comment.