3 ## Tree Estimation Based on Minimum Evolution Algorithm
5 ## Copyright 2007 Vincent Lefort with modifications by
6 ## Emmanuel Paradis (2008)
8 ## This file is part of the R-package `ape'.
9 ## See the file ../COPYING for licensing issues.
11 .fastme <- function(X, nni, lib)
13 if (is.matrix(X)) X <- as.dist(X)
14 N <- as.integer(attr(X, "Size"))
15 labels <- sprintf("%6s", 1:N)
16 edge1 <- edge2 <- integer(2*N - 3)
17 ans <- .C(lib, as.double(X), N, labels, as.integer(nni),
18 edge1, edge2, double(2*N - 3), character(N),
20 labels <- substr(ans[[8]], 1, 6)
21 LABS <- attr(X, "Labels")
22 labels <- if (!is.null(LABS)) LABS[as.numeric(labels)]
23 else gsub("^ ", "", labels)
24 structure(list(edge = cbind(ans[[5]], ans[[6]]), edge.length = ans[[7]],
25 tip.label = labels, Nnode = N - 2),
29 fastme.bal <- function(X, nni = TRUE) .fastme(X, nni, "me_b")
31 fastme.ols <- function(X, nni = TRUE) .fastme(X, nni, "me_o")
35 if (is.matrix(X)) X <- as.dist(X)
36 N <- as.integer(attr(X, "Size"))
37 labels <- sprintf("%6s", 1:N)
38 edge1 <- edge2 <- integer(2*N - 3)
39 ans <- .C("bionj", as.double(X), N, labels, edge1, edge2,
40 double(2*N - 3), character(N), PACKAGE = "ape")
41 labels <- substr(ans[[7]], 1, 6)
42 LABS <- attr(X, "Labels")
43 labels <- if (!is.null(LABS)) LABS[as.numeric(labels)]
44 else gsub("^ ", "", labels)
45 structure(list(edge = cbind(ans[[4]], ans[[5]]), edge.length = ans[[6]],
46 tip.label = labels, Nnode = N - 2),