## Creates a random tree of class phylo4
tree <- rtree4(50)
## Label the nodes of a tree by their nodeId
labelledTree <- idNodeLabel(tree)
plot(labelledTree,show.tip.label=FALSE,show.node.label=TRUE)
## Finds the number of descendants of the nodes
nDescendants(tree)
## Finds the number of tip descendants of the nodes in the tree
nTipDescendants(tree)
## Finds the distance of each node from the root of the tree
dists(tree)
## Finds the length of the internal ladders in the tree
ladderNums(tree)
## Calculates the imbalance of each of the internal nodes
treeImb(tree)
## This returns the Colless imbalance of all subtrees of the tree
## The vector is named by the nodeId of the root of each subtree
nodeApply(tree,colless)
Run the code above in your browser using DataLab