Learn R Programming

treebalance (version 1.2.0)

maxDepth: Calculation of the maximum depth of the tree

Description

This function calculates the maximum depth of any vertex in a rooted tree \(T\), which is at the same time its height \(h(T)\). The tree must not necessarily be binary. Formally, \(h(T)\) is defined as $$h(T)=\max_{v\in V(T)} \delta(v)$$ with \(\delta(v)\) being the depth of the vertex \(v\). The maximum depth is an imbalance index.

For \(n=1\) the function returns \(h(T)=0\) and a warning.

For details on the maximum depth, see also Chapter 23 in "Tree balance indices: a comprehensive survey" (https://doi.org/10.1007/978-3-031-39800-1_23).

Usage

maxDepth(tree)

Value

maxDepth returns the maximum depth, i.e. height, of a tree.

Arguments

tree

A rooted tree in phylo format.

Author

Luise Kuehn, Sophie Kersting

References

C. Colijn and J. Gardy. Phylogenetic tree shapes resolve disease transmission patterns. Evolution, Medicine, and Public Health, 2014(1):96-108, 2014. ISSN 2050-6201. doi: 10.1093/emph/eou018.

Examples

Run this code
tree <- ape::read.tree(text="((((,),),(,)),(((,),),(,)));")
maxDepth(tree)
tree <- ape::read.tree(text="((,),((((,),),),(,)));")
maxDepth(tree)

Run the code above in your browser using DataLab