For each node in a tree, the functions list_offspring and list_parents lists all its offspring and parents, respectively.

list_offspring(x)

list_parents(x)

Arguments

x

An object of class phylo or aphylo.

Value

List of length n (total number of nodes).

Examples

# A simple example with phylo tree ------------------------------------------

set.seed(4)
x <- ape::rtree(10)
list_offspring(x)
#> [[1]]
#> integer(0)
#> 
#> [[2]]
#> integer(0)
#> 
#> [[3]]
#> integer(0)
#> 
#> [[4]]
#> integer(0)
#> 
#> [[5]]
#> integer(0)
#> 
#> [[6]]
#> integer(0)
#> 
#> [[7]]
#> integer(0)
#> 
#> [[8]]
#> integer(0)
#> 
#> [[9]]
#> integer(0)
#> 
#> [[10]]
#> integer(0)
#> 
#> [[11]]
#> [1] 12 19
#> 
#> [[12]]
#> [1] 13 15
#> 
#> [[13]]
#> [1]  1 14
#> 
#> [[14]]
#> [1] 2 3
#> 
#> [[15]]
#> [1] 16 18
#> 
#> [[16]]
#> [1]  4 17
#> 
#> [[17]]
#> [1] 5 6
#> 
#> [[18]]
#> [1] 7 8
#> 
#> [[19]]
#> [1]  9 10
#>