示例#1
0
  private void constructTree() {
    if (merges == null) {
      throw new RuntimeException("merges empty!");
    }
    LOG.info("constructing tree, merge size:{}", merges.size());
    treeData = new DynamicTreeData();

    DendroNode[] nodes = new DendroNode[merges.size() + 1];

    DendroNode current = null;
    DendroNode prev = null;
    // for (Merge m : getMerges()) {

    Merge m;
    for (int i = merges.size() - 1; i >= 0; i--) {
      m = merges.get(i);
      current = new DTreeNode();
      // bottom level
      if (prev == null) {
        prev = getNode(m.remainingCluster());
      }

      current.setLeft(prev);
      current.setRight(getNode(m.mergedCluster()));
      current.setHeight(m.similarity());
      prev = current;
      //  System.out.println("merge: " + m.mergedCluster() + " remain: " + m.remainingCluster() + "
      // similarity = " + m.similarity());
    }
    numNodes = 0;
    // number leaves, so that we can compute it's position
    numberLeaves(current);
    treeData.updatePositions(current);

    treeData.setRoot(current);
    treeData.setLeaves(nodes);
    LOG.info("max tree height: {}", current.getHeight());
  }
示例#2
0
 @Override
 public void setTreeData(DendroTreeData treeData) {
   this.treeData = treeData;
   treeData.updatePositions(treeData.getRoot());
 }