3 ## Tree Estimation Based on Minimum Evolution Algorithm
5 ## Copyright 2007 Vincent Lefort with modifications by
6 ## Emmanuel Paradis (2008-2012)
8 ## This file is part of the R-package `ape'.
9 ## See the file ../COPYING for licensing issues.
11 fastme.bal <- function(X, nni = TRUE, spr = TRUE, tbr = TRUE)
13 if (is.matrix(X)) X <- as.dist(X)
14 N <- as.integer(attr(X, "Size"))
16 ans <- .C("me_b", as.double(X), N, 1:N, as.integer(nni),
17 as.integer(spr), as.integer(tbr), integer(nedge),
18 integer(nedge), double(nedge),
19 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
20 labels <- attr(X, "Labels")
21 if (is.null(labels)) labels <- as.character(1:N)
22 labels <- labels[ans[[3]]]
23 structure(list(edge = cbind(ans[[7]], ans[[8]]),
24 edge.length = ans[[9]],
25 tip.label = labels, Nnode = N - 2L),
29 fastme.ols <- function(X, nni = TRUE)
31 if (is.matrix(X)) X <- as.dist(X)
32 N <- as.integer(attr(X, "Size"))
34 ans <- .C("me_o", as.double(X), N, 1:N, as.integer(nni),
35 integer(nedge), integer(nedge), double(nedge),
36 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
37 labels <- attr(X, "Labels")
38 if (is.null(labels)) labels <- as.character(1:N)
39 labels <- labels[ans[[3]]]
40 structure(list(edge = cbind(ans[[5]], ans[[6]]),
41 edge.length = ans[[7]],
42 tip.label = labels, Nnode = N - 2L),
48 if (is.matrix(X)) X <- as.dist(X)
50 stop("missing values are not allowed in the distance matrix.\nConsider using bionjs()")
52 stop("at least one distance was greater than 100")
53 N <- as.integer(attr(X, "Size"))
55 ans <- .C("bionj", as.double(X), N, integer(2 * N - 3),
56 integer(2 * N - 3), double(2*N - 3),
57 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
58 labels <- attr(X, "Labels")
59 if (is.null(labels)) labels <- as.character(1:N)
60 obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]],
61 tip.label = labels, Nnode = N - 2L)