diff --git a/src/main/java/nl/cwts/networkanalysis/CPMClusteringAlgorithm.java b/src/main/java/nl/cwts/networkanalysis/CPMClusteringAlgorithm.java index f61da6f..a7e8880 100644 --- a/src/main/java/nl/cwts/networkanalysis/CPMClusteringAlgorithm.java +++ b/src/main/java/nl/cwts/networkanalysis/CPMClusteringAlgorithm.java @@ -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; @@ -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];