scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.count#

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

Get the count of nodes in the tree.

Parameters:
tipsbool

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

Returns:
int

The number of nodes or tips

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