TreeNode.
bifurcate
(insert_length=None)[source]¶Reorders the tree into a bifurcating tree.
State: Experimental as of 0.4.2.
All nodes that have more than 2 children will have additional intermediate nodes inserted to ensure that every node has only 2 children.
insert_length (int, optional) – The branch length assigned to all inserted nodes.
See also
Notes
Any nodes that have a single child can be collapsed using the prune method to create strictly bifurcating trees.
Examples
>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b,g,h)c,(d,e)f)root;"])
>>> print(tree.ascii_art())
/-a
|
|--b
/c-------|
| |--g
| |
-root----| \-h
|
| /-d
\f-------|
\-e
>>> tree.bifurcate()
>>> print(tree.ascii_art())
/-h
/c-------|
| | /-g
| \--------|
| | /-a
-root----| \--------|
| \-b
|
| /-d
\f-------|
\-e