skbio.core.tree.TreeNode.count

TreeNode.count(tips=False)[source]

Get the count of nodes in the tree

Parameters:

tips : bool

If True, only return the count of the number of tips

Returns:

int

The number of nodes or tips

Examples

>>> from skbio.core.tree import TreeNode
>>> tree = TreeNode.from_newick("((a,(b,c)d)e,(f,g)h)i;")
>>> print tree.count()
9
>>> print tree.count(tips=True)
5