height: Height of a tree

Description Usage Arguments Value Examples

Description

This function returns the height of a tree, defined as the number of nodes of the longest subchain. For an empty tree, the height is conventionally equal to 0.

Usage

1
2
3
4
5
6
height(.tree)

## S3 method for class 'rtree'
height(.tree)

height(x) <- value

Arguments

.tree, x

A tree.

value

integer. Height to assign to the tree x (this calls the function prune).

Value

An integer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Rooted tree
(tr0 = c_("Bob", "Carl", "Daniel"))
tr1 = r_("Dimitri", s = list(c_("Enoc"), c_("Ferdinand")))
tr1 = r_("Caroline", s = list(tr1))
(tr1 = r_("Bill", s = list(tr1)))
(tr2 = r_("Alice", s = list(tr0, tr1)))
height(empty_tree())
height(tr0)
height(tr1)
height(tr2)

## Unrooted tree
(tr3 = r_(s = list(tr2, c_("Grand-Mother", "Father", "Son"))))
height(tr3)

paulponcet/oak documentation built on May 14, 2019, 7:21 p.m.