skbio.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 six import StringIO
>>> from skbio import TreeNode
>>> tree = TreeNode.read(StringIO("((a,(b,c)d)e,(f,g)h)i;"))
>>> print(tree.count())
9
>>> print(tree.count(tips=True))
5