skbio.tree.TreeNode.count#

TreeNode.count(tips=False)[source]#

Get the count of nodes in the tree.

Parameters:
tipsbool, optional

If True, only return the count of tips (default: False).

Returns:
int

The number of nodes.

Examples

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