use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusterPostProcessingTask in project clusterMaker2 by RBVI.
the class PP_DivideAndRecluster method run.
public void run() {
/* print score before any post processing */
// double scoreAtStart = this.cc.getClusteringScore();
// System.out.println("Score before post processing: "+scoreAtStart);
/* merging step */
ArrayList<ArrayList<Integer>> clusterObject = PostProcessingUtility.createClusterObject(this.cc, false);
HashSet<String> alreadyCompared = new HashSet<String>();
ClusterObjectComparator comparator = new ClusterObjectComparator();
PostProcessingUtility.mergeCluster(clusterObject, alreadyCompared, this.cc, comparator, true);
this.bestScore = PostProcessingUtility.updateClusterInfoInCC(clusterObject, this.cc);
/* collection ConnectedComponent objects */
ArrayList<ConnectedComponent> cCsOfSubgraphs = new ArrayList<ConnectedComponent>();
/* start a new clustering procedure for clusters larger than 3 */
for (int i = 0; i < clusterObject.size(); i++) {
ArrayList<Integer> cluster = clusterObject.get(i);
int clusterSize = cluster.size();
/* if the clusters are to small, leave them in the clusters object and continue */
if (clusterSize <= 3) {
// System.out.println("cluster too small: "+cluster.toString());
continue;
}
/* remove cluster from cluster object and decrease i */
// TODO!!
clusterObject.remove(i);
--i;
ConnectedComponent ccForCluster = this.cc.createConnectedComponentForCluster(i, cluster);
cCsOfSubgraphs.add(ccForCluster);
ClusterPostProcessingTask clusterTask = new ClusterPostProcessingTask(ccForCluster, this.params, this.layouterEnumTypes);
clusterTask.run();
}
for (int i = 0; i < cCsOfSubgraphs.size(); i++) {
ConnectedComponent subCC = cCsOfSubgraphs.get(i);
addClustersToTotalClusters(subCC, clusterObject);
}
/* update clustering information */
this.bestScore = PostProcessingUtility.updateClusterInfoInCC(clusterObject, this.cc);
/* do post post processing - merge and rearrange */
PP_RearrangeAndMergeBest postProcess1 = new PP_RearrangeAndMergeBest();
postProcess1.initPostProcessing(this.cc);
postProcess1.run();
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusterPostProcessingTask in project clusterMaker2 by RBVI.
the class PP_DivideAndReclusterRecursively method recursiveReclustering.
/**
* This method goes through each cluster in the tmpClusterObject and
* re-clusters them. If the clusters have less than 4 objects, then it is
* added to the finalClusterObject. If after the re-clustering, no changes
* have occured (it is still one cluster) it is added to the
* finalClusterObject. Otherwise if changes have occured the sub-clusters
* are then re-clustered again. This occurs recursively until no more
* improvements are found.
*
* @param finalClusterObject
* This should only include finished clusters that can not be
* improved anymore by reclustering.
* @param tmpClusterObject
* This includes all clusters that are to be re-clustered.
*/
private void recursiveReclustering(ArrayList<ArrayList<Integer>> finalClusterObject, ArrayList<ArrayList<Integer>> tmpClusterObject) {
for (int i = 0; i < tmpClusterObject.size(); i++) {
ArrayList<Integer> cluster = tmpClusterObject.get(i);
int clusterSize = cluster.size();
/*all clusters <=3 are taken care of in the rearrange method of
* post-processing */
if (clusterSize <= 3) {
finalClusterObject.add(cluster);
} else {
/* run clustering for this one cluster to see if an improvement can be found */
ConnectedComponent ccForCluster = this.cc.createConnectedComponentForCluster(i, cluster);
ClusterPostProcessingTask clusterTask = new ClusterPostProcessingTask(ccForCluster, this.params, this.layouterEnumTypes);
clusterTask.run();
/* if there has been no change, add this cluster to the final cluster object */
if (ccForCluster.getNumberOfClusters() == 1) {
finalClusterObject.add(cluster);
/* otherwise recluster */
} else {
/* new cluster object for the resulting clusters of the improved cluster */
ArrayList<ArrayList<Integer>> nextClusterObject = PostProcessingUtility.createClusterObject(ccForCluster, true);
recursiveReclustering(finalClusterObject, nextClusterObject);
}
}
}
}
Aggregations