Skip to main content
`Ctrl`+`K`

# skbio.tree.TreeNode.unrooted_move

TreeNode.unrooted_move(branch_attrs={'length', 'support'}, uncache=True)

  Walk the tree unrooted-style and rearrange it.

  Added in version 0.6.2.

  Changed in version 0.6.3: The underlying algorithm is now iterative instead of recursive, therefore won’t be constrained by Python’s maximum recursion limit when working with large trees. Parameter `parent` was removed as it is no longer needed.

  Parameters:
    parent TreeNode or None

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

    branch_attrs set of str, optional

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

    uncache bool, optional

      Whether to clear caches of the tree if present (default: True). See `details`.

      Added in version 0.6.3.

  See also

  `root_at`
  `unrooted_copy`

  Notes

  This method 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.

  Examples

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