3 ## Neighbor-Joining Tree Estimation
5 ## Copyright 2004-2006 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 edge1 <- edge2 <- integer(2*N - 3)
17 edge.length <- numeric(2*N - 3)
18 ans <- .C("nj", as.double(X), as.integer(N), as.integer(edge1),
19 as.integer(edge2), as.double(edge.length), PACKAGE = "ape")
20 obj <- list(edge = cbind(ans[[3]], ans[[4]]),
21 edge.length = ans[[5]], tip.label = labels)