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