R/PathLengths.R
PathLengths.Rd
Given a weighted rooted tree tree
, PathLengths()
returns the distance
from each vertex to each of its descendant vertices.
PathLengths(tree, fullMatrix = FALSE)
Original tree of class phylo
, in Preorder
.
Logical specifying return format; see "value" section`.
If fullMatrix = TRUE
, PathLengths()
returns a square matrix in
which entry [i, j]
denotes the distance from internal node i
to the
descendant vertex j
.
Vertex pairs without a continuous directed path are denoted NA
.
If fullMatrix = FALSE
, PathLengths()
returns a data.frame
with three
columns: start
lists the deepest node in each path (i.e. that closest
to the root); end
lists the shallowest node (i.e. that closest to a leaf);
length
lists the total length of that path.
Other tree properties:
ConsensusWithout()
,
NSplits()
,
NTip()
,
SplitsInBinaryTree()
,
TipLabels()
,
TreeIsRooted()
tree <- rtree(6)
plot(tree)
add.scale.bar()
nodelabels()
tiplabels()
PathLengths(tree)
#> start end length
#> 1 7 1 0.20269226
#> 2 7 2 1.07830166
#> 3 8 2 0.36718043
#> 4 9 2 0.24548851
#> 5 7 3 1.21574694
#> 6 8 3 0.50462572
#> 7 9 3 0.38293379
#> 8 10 3 0.23962942
#> 9 7 4 1.03505190
#> 10 8 4 0.32393068
#> 11 9 4 0.20223876
#> 12 10 4 0.05893438
#> 13 7 5 2.22967869
#> 14 8 5 1.51855747
#> 15 11 5 0.87626921
#> 16 7 6 2.13232416
#> 17 8 6 1.42120294
#> 18 11 6 0.77891468
#> 19 7 8 0.71112122
#> 20 7 9 0.83281314
#> 21 8 9 0.12169192
#> 22 7 10 0.97611752
#> 23 8 10 0.26499630
#> 24 9 10 0.14330438
#> 25 7 11 1.35340948
#> 26 8 11 0.64228826