skbio.tree.TreeNode.is_bifurcating#
- TreeNode.is_bifurcating(strict=False)[source]#
Check if the tree is bifurcating.
Added in version 0.6.3.
- Parameters:
- strictbool, optional
Whether to consider single-child nodes as violations of bifurcation. Default is False.
Notes
In a bifurcating tree (a.k.a. binary tree), every node has at most two children. The property of bifurcation is necessary for a wide range of tree analyses. In contrast, if a node has three or more children, it is considered as multifurcating, or polytomy in phylogenetics.
In strict mode, every internal node (including root) has to have exactly two children in order for the tree to be bifurcating. Single-child nodes are considered as violations. These nodes can be collapsed by
prune()
.This method operates on the subtree below the current node.
Examples
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a,b,c),(d,e))root;"]) >>> tree.is_bifurcating() False