3 ## Neighbor-Joining Tree Estimation
5 ## Copyright 2004-2009 Emmanuel Paradis
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
12 if (is.matrix(X)) X <- as.dist(X)
14 labels <- attr(X, "Labels")
15 if (is.null(labels)) labels <- as.character(1:N)
16 ans <- .C("nj", as.double(X), as.integer(N), integer(2*N - 3),
17 integer(2*N - 3), double(2*N - 3),
18 DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")
19 obj <- list(edge = cbind(ans[[3]], ans[[4]]), edge.length = ans[[5]],
20 tip.label = labels, Nnode = N - 2L)