コード例 #1
0
ファイル: HClustResult.java プロジェクト: deric/clueminer
 private void subtreeToCluster(DendroNode node, Cluster c, int[] assign) {
   if (node.isLeaf()) {
     if (treeData.containsClusters()) {
       DClusterLeaf<E> leaf = (DClusterLeaf) node;
       for (E instance : leaf.getInstances()) {
         c.add(instance);
         assign[instance.getIndex()] = c.getClusterId();
       }
     } else {
       c.add(((DendroLeaf) node).getData());
       assign[node.getId()] = c.getClusterId();
     }
   } else {
     subtreeToCluster(node.getLeft(), c, assign);
     subtreeToCluster(node.getRight(), c, assign);
   }
 }
コード例 #2
0
ファイル: HClustResult.java プロジェクト: deric/clueminer
 private void checkCutoff(DendroNode node, double cutoff, Clustering clusters, int[] assign) {
   if (node.isLeaf()) {
     if (treeData.containsClusters()) {
       DClusterLeaf<E> leaf = (DClusterLeaf) node;
       Cluster clust = makeCluster(clusters);
       for (E instance : leaf.getInstances()) {
         clust.add(instance);
         assign[instance.getIndex()] = clust.getClusterId();
       }
     }
     return;
   }
   if (node.getHeight() == cutoff) {
     // both branches goes to the same cluster
     Cluster clust = makeCluster(clusters);
     subtreeToCluster(node, clust, assign);
   } else if (node.getLeft().getHeight() < cutoff || node.getRight().getHeight() < cutoff) {
     Cluster clust;
     if (node.getLeft().getHeight() < cutoff && node.getRight().getHeight() < cutoff) {
       clust = makeCluster(clusters);
       subtreeToCluster(node.getLeft(), clust, assign);
       clust = makeCluster(clusters);
       subtreeToCluster(node.getRight(), clust, assign);
     } else if (node.getRight().getHeight() < cutoff) {
       clust = makeCluster(clusters);
       subtreeToCluster(node.getRight(), clust, assign);
       checkCutoff(node.getLeft(), cutoff, clusters, assign);
     } else if (node.getLeft().getHeight() < cutoff) {
       clust = makeCluster(clusters);
       subtreeToCluster(node.getLeft(), clust, assign);
       checkCutoff(node.getRight(), cutoff, clusters, assign);
     }
   } else {
     checkCutoff(node.getLeft(), cutoff, clusters, assign);
     checkCutoff(node.getRight(), cutoff, clusters, assign);
   }
 }