1 ## cophenetic.phylo.R (2012-08-14)
3 ## Pairwise Distances from a Phylogenetic Tree
5 ## Copyright 2006-2012 Emmanuel Paradis
7 ## This file is part of the R-package `ape'.
8 ## See the file ../COPYING for licensing issues.
10 dist.nodes <- function(x)
12 x <- reorder(x) # required for the C code
17 d <- .C("dist_nodes", as.integer(n), as.integer(m),
18 as.integer(x$edge[, 1] - 1L), as.integer(x$edge[, 2] - 1L),
19 as.double(x$edge.length), as.integer(Nedge(x)),
20 double(nm * nm), DUP = FALSE, NAOK = TRUE,
23 dimnames(d) <- list(1:nm, 1:nm)
27 cophenetic.phylo <- function(x)
29 n <- length(x$tip.label)
30 ans <- dist.nodes(x)[1:n, 1:n]
31 dimnames(ans)[1:2] <- list(x$tip.label)