Skip to content

Commit

Permalink
Use clusterWeights function (#17)
Browse files Browse the repository at this point in the history
* Use clusterWeights function.

* Revert using getClusterWeights when array needs to be larger.
  • Loading branch information
vtraag authored Dec 17, 2020
1 parent 42fdd9e commit a3f342d
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ public double calcQuality(Network network, Clustering clustering)
}
quality += network.totalEdgeWeightSelfLinks;

clusterWeights = new double[clustering.nClusters];
for (i = 0; i < network.nNodes; i++)
clusterWeights[clustering.clusters[i]] += network.nodeWeights[i];
clusterWeights = clustering.getClusterWeights(network);

for (i = 0; i < clustering.nClusters; i++)
quality -= clusterWeights[i] * clusterWeights[i] * resolution;

Expand All @@ -156,11 +155,11 @@ public int removeCluster(Network network, Clustering clustering, int cluster)
double[] clusterWeights, totalEdgeWeightPerCluster;
int i, j;

clusterWeights = new double[clustering.nClusters];
clusterWeights = clustering.getClusterWeights(network);

totalEdgeWeightPerCluster = new double[clustering.nClusters];
for (i = 0; i < network.nNodes; i++)
{
clusterWeights[clustering.clusters[i]] += network.nodeWeights[i];
if (clustering.clusters[i] == cluster)
for (j = network.firstNeighborIndices[i]; j < network.firstNeighborIndices[i + 1]; j++)
totalEdgeWeightPerCluster[clustering.clusters[network.neighbors[j]]] += network.edgeWeights[j];
Expand Down

0 comments on commit a3f342d

Please sign in to comment.