Skip to contents

Number of nodes that must be traversed to navigate from each edge to each other edge within a tree

Usage

EdgeDistances(tree)

Arguments

tree

A tree of class phylo.

Value

EdgeDistances() returns a symmetrical matrix listing the number of edges that must be traversed to travel from each numbered edge to each other. The two edges straddling the root of a rooted tree are treated as a single edge. Add a "root" tip using AddTip() if the position of the root is significant.

Examples


tree <- BalancedTree(5)
plot(tree)
ape::edgelabels()


EdgeDistances(tree)
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,]    0    1    2    2    1    0    1    1
#> [2,]    1    0    1    1    1    1    2    2
#> [3,]    2    1    0    1    2    2    3    3
#> [4,]    2    1    1    0    2    2    3    3
#> [5,]    1    1    2    2    0    1    2    2
#> [6,]    0    1    2    2    1    0    1    1
#> [7,]    1    2    3    3    2    1    0    1
#> [8,]    1    2    3    3    2    1    1    0