-## is.ultrametric.R (2007-12-18)
+## is.ultrametric.R (2009-05-10)
## Test if a Tree is Ultrametric
-## Copyright 2003-2007 Emmanuel Paradis
+## Copyright 2003-2009 Emmanuel Paradis
## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.
is.ultrametric <- function(phy, tol = .Machine$double.eps^0.5)
{
-### the tree must be in cladewise order
- if (class(phy) != "phylo")
+ if (!inherits(phy, "phylo"))
stop('object "phy" is not of class "phylo".')
if (is.null(phy$edge.length))
stop("the tree has no branch lengths.")
+ phy <- reorder(phy)
n <- length(phy$tip.label)
n.node <- phy$Nnode