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

    if (children != null) {
      for (Node child : children) {
        child.removeNodeListenerFromSubtree(listener);
      }
    }
  }
Beispiel #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());
  }
Beispiel #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;
  }
Beispiel #4
0
 public boolean shallowEquals(Node obj) {
   return this.getId() == obj.getId() && this.getLabel().equals(obj.getLabel());
 }