static int calculateH(final ArrayList<Integer> counts) { int h = 0; for (int i = 0; i < counts.size() - 1; i++) { for (int j = i + 1; j < counts.size(); j++) { h += counts.get(i) * counts.get(j); } } return h; }
int calculateH(Cluster cluster) { final Map<Object, Integer> documentCountByPartition = getDocumentCountByPartition(cluster.getAllDocuments()); final ArrayList<Integer> counts = Lists.newArrayList(); counts.addAll(documentCountByPartition.values()); return calculateH(counts); }
static int calculateWorstCaseH(int clusterSize, int partitionCount) { final ArrayList<Integer> counts = Lists.newArrayList(); for (int partition = 0; partition < partitionCount; partition++) { counts.add( clusterSize / partitionCount + (partition < (clusterSize % partitionCount) ? 1 : 0)); } return calculateH(counts); }