in src/main/java/com/twitter/sbf/core/MHAlgorithm.java [139:167]
private SparseBinaryMatrix removeSmallClusters(SparseBinaryMatrix z, int minClusterSize) {
diagnosticsWriter.format(
"Going to remove columns with fewer than %d nonzeros\n", minClusterSize
);
diagnosticsWriter.flush();
int numRemoved = 0;
ImmutableList.Builder<IntSet> newCols = new ImmutableList.Builder<>();
for (int i = 0; i < z.getNumCols(); i++) {
if (z.getColumn(i).size() >= minClusterSize) {
newCols.add(z.getColumn(i));
} else {
numRemoved++;
}
}
ImmutableList<IntSet> newColsList = newCols.build();
IntSet[] newColsArray =
Arrays.copyOf(newColsList.toArray(), newColsList.size(), IntSet[].class);
SparseBinaryMatrix newZ = new SparseBinaryMatrix(g.getNumVertices(), newColsArray.length);
newZ.initFromColSets(newColsArray);
diagnosticsWriter.println(getMetricsLine(newZ, 0, 0, 0, 0, true));
diagnosticsWriter.format("Removed %d clusters which are smaller than %d\n",
numRemoved, minClusterSize);
diagnosticsWriter.flush();
return newZ;
}