TreeNode.unrooted_move(parent=None, branch_attrs={'length', 'support'})[source]#

Walk the tree unrooted-style and rearrange it.

Added in version 0.6.2.

parentTreeNode or None

Direction of walking (from parent to self). If specified, walking to the parent will be prohibited.

branch_attrsset of str, optional

Attributes of TreeNode objects that should be considered as branch attributes during the operation.


This method recursively walks a tree from a given node in an unrooted style (i.e., directions of branches are not assumed). It rerranges the tree such that the given node becomes the root node and all other nodes are re-positioned accordingly, whereas the topology remains the same.

This method manipulates the tree in place. There is no return value. The new tree should be referred to by the node where the operation started, as it has become the new root node.


>>> from skbio import TreeNode
>>> tree =["((a,(b,c)d)e,(f,g)h)i;"])
>>> new_root = tree.find('d')
>>> new_root.unrooted_move()
>>> print(new_root)