| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/nleaves.R |
| 3 |
\name{nnodes} |
| 4 |
\alias{nnodes} |
| 5 |
\alias{nnodes.default} |
| 6 |
\alias{nnodes.dendrogram} |
| 7 |
\alias{nnodes.hclust} |
| 8 |
\alias{nnodes.phylo} |
| 9 |
\title{Counts the number of nodes (Vertices) in a tree} |
| 10 |
\usage{ |
| 11 |
nnodes(x, ...) |
| 12 |
|
| 13 |
\method{nnodes}{default}(x, ...) |
| 14 |
|
| 15 |
\method{nnodes}{dendrogram}(x, ...) |
| 16 |
|
| 17 |
\method{nnodes}{hclust}(x, ...) |
| 18 |
|
| 19 |
\method{nnodes}{phylo}(x, ...) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{x}{tree object (dendrogram or hclust)} |
| 23 |
|
| 24 |
\item{...}{not used} |
| 25 |
} |
| 26 |
\value{ |
| 27 |
The number of leaves in the tree |
| 28 |
} |
| 29 |
\description{ |
| 30 |
Counts the number of nodes in a tree (dendrogram, hclust, phylo). |
| 31 |
} |
| 32 |
\details{ |
| 33 |
The idea for the name is from functions like ncol, and nrow. |
| 34 |
|
| 35 |
The phylo method is based on turning the phylo to hclust and than to |
| 36 |
dendrogram. It may not work for complex phylo trees. |
| 37 |
} |
| 38 |
\examples{ |
| 39 |
hc <- hclust(dist(USArrests[1:5, ]), "ave") |
| 40 |
dend <- as.dendrogram(hc) |
| 41 |
|
| 42 |
nnodes(dend) # 9 |
| 43 |
nnodes(hc) # 9 |
| 44 |
} |
| 45 |
\seealso{ |
| 46 |
\link{nrow}, \link{count_terminal_nodes}, \link{nleaves} |
| 47 |
} |