3 \title{Calculate Numbers of Phylogenetic Trees}
5 howmanytrees(n, rooted = TRUE, binary = TRUE,
6 labeled = TRUE, detail = FALSE)
9 \item{n}{a positive numeric integer giving the number of tips.}
10 \item{rooted}{a logical indicating whether the trees are rooted
11 (default is \code{TRUE}).}
12 \item{binary}{a logical indicating whether the trees are bifurcating
13 (default is \code{TRUE}).}
14 \item{labeled}{a logical indicating whether the trees have tips
15 labeled (default is \code{TRUE}).}
16 \item{detail}{a logical indicating whether the eventual intermediate
17 calculations should be returned (default is \code{FALSE}). This
18 applies only for the multifurcating trees, and the bifurcating,
19 rooted, unlabeled trees (aka tree shapes).}
22 This function calculates the number of possible phylogenetic trees for
23 a given number of tips.
26 In the cases of labeled binary trees, the calculation is done directly
27 and a single numeric value is returned.
29 For multifurcating trees, and bifurcating, rooted, unlabeled trees,
30 the calculation is done iteratively for 1 to \code{n} tips. Thus the
31 user can print all the intermediate values if \code{detail = TRUE}, or
32 only a single value if \code{detail = FALSE} (the default).
34 For multifurcating trees, if \code{detail = TRUE}, a matrix is
35 returned with the number of tips as rows (named from \code{1} to
36 \code{n}), and the number of nodes as columns (named from \code{1} to
37 \code{n - 1}). For bifurcating, rooted, unlabeled trees, a vector is
38 returned with names equal to the number of tips (from \code{1} to
41 The number of unlabeled trees (aka tree shapes) can be computed only
42 for the rooted binary cases.
44 Note that if an infinite value (\code{Inf}) is returned this does not
45 mean that there is an infinite number of trees (this cannot be if the
46 number of tips is finite), but that the calculation is beyond the
47 limits of the computer.
50 a single numeric value, or in the case where \code{detail = TRUE} is
51 used, a named vector or matrix.
54 Felsenstein, J. (2004) \emph{Inferring phylogenies}. Sunderland:
57 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
59 ### Table 3.1 in Felsenstein 2004:
60 for (i in c(1:20, 30, 40, 50))
61 cat(paste(i, howmanytrees(i), sep = "\t"), sep ="\n")
63 howmanytrees(8, binary = FALSE, detail = TRUE)