private List<ClusterDendogram> clusterIsolateList( IsolateSimilarityMatrix similarityMatrix, List<Isolate> isolates, Cluster.distType type) { // represent fecal samples List<ClusterDendogram> clusterB = new ArrayList<ClusterDendogram>(); // represent fecal samples List<ClusterDendogram> clusterF = new ArrayList<ClusterDendogram>(); // represent immediate (after) samples List<ClusterDendogram> clusterI = new ArrayList<ClusterDendogram>(); // represent later samples List<ClusterDendogram> clusterL = new ArrayList<ClusterDendogram>(); List<ClusterDendogram> clusterD = new ArrayList<ClusterDendogram>(); // clusters resulting from clustering the above clusters will be placed in // clusters and this will prevent me from having to refactor the rest of this // method. List<ClusterDendogram> clusters = new ArrayList<ClusterDendogram>(); for (Isolate sample : isolates) { Cluster newCluster = new Cluster(similarityMatrix, sample); Dendogram newDendogram = new DendogramLeaf(sample); switch (sample.getSampleMethod()) { case FECAL: clusterF.add(new ClusterDendogram(newCluster, newDendogram)); break; case IMM: clusterI.add(new ClusterDendogram(newCluster, newDendogram)); break; case LATER: clusterL.add(new ClusterDendogram(newCluster, newDendogram)); break; case DEEP: clusterD.add(new ClusterDendogram(newCluster, newDendogram)); break; case BEFORE: clusterB.add(new ClusterDendogram(newCluster, newDendogram)); break; default: System.err.println("serious error here"); break; } } // System.out.printf("clusterList size: %d\n", clusters.size()); // cluster within each group clusterF = clusterGroup(clusterF, type); clusterI = clusterGroup(clusterI, type); clusterL = clusterGroup(clusterL, type); clusterD = clusterGroup(clusterD, type); clusterB = clusterGroup(clusterB, type); // cluster each group together: // F and I together first since they are the closest in time // F_I and L next since they are the next closest in time // was going to use "clusterAcrossGroup" but there seemed to be a lot of // logical traps such as where to put clusters that are combined and all of // the problems that followed from that clusters.addAll(clusterF); clusters.addAll(clusterD); clusters = clusterGroup(clusters, type); clusters.addAll(clusterI); clusters = clusterGroup(clusters, type); clusters.addAll(clusterL); clusters = clusterGroup(clusters, type); clusters.addAll(clusterB); clusters = clusterGroup(clusters, type); // clusters within all the day's clusters // based on the above clusterGroup call this would likely be repetitive // clusters = clusterGroup(clusters, type); return clusters; }