PathLengths: Calculate length of paths between each pair of vertices...

View source: R/PathLengths.R

PathLengthsR Documentation

Calculate length of paths between each pair of vertices within tree

Description

Given a weighted rooted tree tree, PathLengths() returns the distance from each vertex to each of its descendant vertices.

Usage

PathLengths(tree, fullMatrix = FALSE)

Arguments

tree

Original tree of class phylo, in Preorder.

fullMatrix

Logical specifying return format; see "value" section'.

Value

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.

Author(s)

Martin R. Smith (martin.smith@durham.ac.uk)

See Also

Other tree properties: ConsensusWithout(), MatchEdges(), NSplits(), NTip(), NodeNumbers(), SplitsInBinaryTree(), TipLabels(), TreeIsRooted()

Examples

tree <- rtree(6)
plot(tree)
add.scale.bar()
nodelabels()
tiplabels()
PathLengths(tree)

TreeTools documentation built on Sept. 11, 2024, 8:27 p.m.