예제 #1
0
  public void removeNodeListenerFromSubtree(NodeListener listener) {
    removeNodeListener(listener);

    if (children != null) {
      for (Node child : children) {
        child.removeNodeListenerFromSubtree(listener);
      }
    }
  }
예제 #2
0
  @Override
  public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof Node)) {
      return false;
    }

    Node that = (Node) obj;

    return this.shallowEquals(that) && Arrays.equals(this.getChildren(), that.getChildren());
  }
예제 #3
0
  private double findMaximumDistanceToLeaf(double currentDistance) {
    double localMaximum = currentDistance;

    int numChildren = this.getNumberOfChildren();
    if (0 < numChildren) {
      for (int i = 0; i < numChildren; ++i) {
        Node child = this.getChild(i);
        double distance = child.findMaximumDistanceToLeaf(currentDistance);

        if (distance > localMaximum) {
          localMaximum = distance;
        }
      }
    }

    double branchLength = this.getBranchLength() != null ? this.getBranchLength() : 0.0;
    return localMaximum + branchLength;
  }
예제 #4
0
 public boolean shallowEquals(Node obj) {
   return this.getId() == obj.getId() && this.getLabel().equals(obj.getLabel());
 }