public class NodeUtils
Helper routines for dealing with nodes.
public static void getExternalNodes(Node root, java.util.Vector store)
Appends all external nodes from tree defined by root to Vector store
root - The root node defining treestore - Where leaf nodes are stored (original contents is not touched)public static Node[] getExternalNodes(Node root)
Obtains all external nodes from tree defined by root and returns as an array
root - The root node defining treepublic static void getInternalNodes(Node root, java.util.Vector store)
Appends all internal nodes from tree defined by root to Vector store
root - The root node defining treestore - Where internal nodes are stored (original contents is not touched)public static Node[] getInternalNodes(Node root, boolean includeRoot)
Obtains all internal nodes from tree defined by root and returns as an array
root - The root node defining treepublic static int getMaxNodeDepth(Node root)
public static kotlin.Array[] getPathLengthInfo(Node root)
Calculates max/min lengths of paths from root to leaf, taking into account branch lengths
public static double getMaximumPathLengthLengthToLeaf(Node root)
public static double getMinimumPathLengthLengthToLeaf(Node root)
public static void lengths2Heights(Node root)
Converts lengths to heights, *without* assuming contemporaneous tips.
public static int getInternalNodeCount(Node root)
public static void lengths2HeightsKeepTips(Node node, boolean useMax)
Converts lengths to heights, but maintains tip heights.
public static void exchangeInfo(Node node1, Node node2)
Exchange field info between two nodes. Specifically identifiers, branch lengths, node heights and branch length SEs.
public static void heights2Lengths(Node node)
determines branch lengths of this and all descendent nodes from heights
public static void heights2Lengths(Node node, boolean respectMinimum)
determines branch lengths of this and all descendent nodes from heights
public static void localHeights2Lengths(Node node, boolean respectMinimum)
determines branch lengths of this node and its immediate descendent nodes from heights.
public static double findLargestChild(Node node)
Finds the largest child (in terms of node height).
public static void removeBranch(Node node)
remove internal branch (collapse node with its parent)
node - node associated with internal branchpublic static void restoreBranch(Node node)
restore internal branch
node - node associated with internal branchpublic static void joinChilds(Node node, int n1, int n2)
join two childs, introducing a new node/branch in the tree that replaces the first child
n1 - number of first childn2 - number of second childpublic static Node preorderSuccessor(Node node)
determine preorder successor of this node
public static Node postorderSuccessor(Node node)
determine postorder successor of a node
public static void printNH(java.io.PrintWriter out,
Node node,
boolean printLengths,
boolean printInternalLabels)
prints node in New Hamshire format.
public static int printNH(java.io.PrintWriter out,
Node node,
boolean printLengths,
boolean printInternalLabels,
int column,
boolean breakLines)
public static Node[] findByIdentifier(Node node, java.lang.String[] identifierNames)
Returns the first nodes in this tree that has the required identifiers.
public static Node[] findByIdentifier(Node node, Taxon[] identifiers)
Returns the first nodes in this tree that has the required identifiers.
public static Node findByIdentifier(Node node, Taxon identifier)
Returns the first node in this tree that has the required identifier.
public static Node findByIdentifier(Node node, java.lang.String identifierName)
Returns the first node in this tree that has the required identifier.
public static double getDistanceToRoot(Node node)
determine distance to root
public static int getLeafCount(Node node)
Return the number of terminal leaves below this node or 1 if this is a terminal leaf.
public static boolean isAncestor(Node possibleAncestor, Node node)
For two nodes in the tree true if the first node is the ancestor of the second
possibleAncestor - the node that may be the ancestor of the other nodenode - the node that may have the other node as it's ancestorpublic static Node getFirstCommonAncestor(Node[] nodes)
For a set of nodes in the tree returns the common ancestor closest to all nodes (most recent common ancestor)
nodes - the nodes to check, is okay if array elements are null!public static Node getFirstCommonAncestor(Node nodeOne, Node nodeTwo)
For two nodes in the tree returns the common ancestor closest to both nodes (most recent common ancestor)
nodeOne - nodeTwo - public static int getUnrootedBranchCount(Node center)
returns number of branches centered around an internal node in an unrooted tree
public static void convertNegativeBranchLengthsToZeroLength(Node node)
If the given node or the sub tree defined by that node have negative branch lengths, they'll have zeron branch lengths after a call to this function!