As the name implies. This can also work for non-dendrogram nested lists.

min_depth(dend, ...)

max_depth(dend, ...)

Arguments

dend

Any nested list object (including dendrogram).

...

unused at the moment.

Value

Integer, the (min/max) number of nodes from the root to the leafs

Examples


hc <- hclust(dist(USArrests), "ave")
(dend1 <- as.dendrogram(hc)) # "print()" method
#> 'dendrogram' with 2 branches and 50 members total, at height 152.314 
is.list(dend1)
#> [1] TRUE
is.list(dend1[[1]][[1]][[1]])
#> [1] FALSE
dend1[[1]][[1]][[1]]
#> 'dendrogram' leaf 'Florida', at height 0 
plot(dend1)

min_depth(dend1)
#> [1] 4
max_depth(dend1)
#> [1] 10