find_farthest_tip_pair {castor} R Documentation

## Find the two most distant tips in a tree.

### Description

Given a phylogenetic tree, find the two most phylogenetically distant tips (to each other) in the tree.

### Usage

```find_farthest_tip_pair(tree, as_edge_counts = FALSE)
```

### Arguments

 `tree` A rooted tree of class "phylo". While the tree must be rooted for technical reasons, the outcome does not actually depend on the rooting. `as_edge_counts` Logical, specifying whether to count phylogenetic distance in terms of edge counts instead of cumulative edge lengths. This is the same as setting all edge lengths to 1.

### Details

If `tree\$edge.length` is missing or NULL, then each edge is assumed to have length 1. The tree may include multi-furcations as well as mono-furcations (i.e. nodes with only one child).

The asymptotic time complexity of this function is O(Nedges), where Nedges is the number of edges in the tree.

### Value

A named list with the following elements:

 `tip1` An integer between 1 and Ntips, specifying the first of the two most distant tips. `tip2` An integer between 1 and Ntips, specifying the second of the two most distant tips. `distance` Numeric, specifying the phylogenetic (patristic) distance between the `farthest_tip1` and `farthest_tip2`.

### Author(s)

Stilianos Louca

`find_nearest_tips`, `find_farthest_tips`

### Examples

```# generate a random tree
Ntips = 1000
parameters = list(birth_rate_intercept=1,death_rate_intercept=0.9)
tree = generate_random_tree(parameters,Ntips,coalescent=FALSE)\$tree

# find farthest pair of tips
results = find_farthest_tip_pair(tree)

# print results
cat(sprintf("Tip %d and %d have distance %g\n",
results\$tip1,results\$tip2,results\$distance))
```

[Package castor version 1.7.0 Index]