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 obj <- list(edge = cbind(ans[[7]], ans[[8]]),
24 edge.length = ans[[9]],
25 tip.label = labels, Nnode = N - 2L)
27 attr(obj, "order") <- "cladewise"
31 fastme.ols <- function(X, nni = TRUE)
33 if (is.matrix(X)) X <- as.dist(X)
34 N <- as.integer(attr(X, "Size"))
36 ans <- .C("me_o", as.double(X), N, 1:N, as.integer(nni),
37 integer(nedge), integer(nedge), double(nedge),
38 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
39 labels <- attr(X, "Labels")
40 if (is.null(labels)) labels <- as.character(1:N)
41 labels <- labels[ans[[3]]]
42 obj <- list(edge = cbind(ans[[5]], ans[[6]]),
43 edge.length = ans[[7]],
44 tip.label = labels, Nnode = N - 2L)
46 attr(obj, "order") <- "cladewise"
52 if (is.matrix(X)) X <- as.dist(X)
54 stop("missing values are not allowed in the distance matrix.\nConsider using bionjs()")
56 stop("at least one distance was greater than 100")
57 N <- as.integer(attr(X, "Size"))
59 ans <- .C("bionj", as.double(X), N, integer(2 * N - 3),
60 integer(2 * N - 3), double(2*N - 3),
61 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
62 labels <- attr(X, "Labels")
63 if (is.null(labels)) labels <- as.character(1:N)
64 obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]],
65 tip.label = labels, Nnode = N - 2L)