Navigation Banner
 

RerootTree Built-in function
  Returns a string containing the Newick style string of the tree rerooted at a specified branch.
Syntax  res = RerootTree(tree_ident, branch_name);
res = RerootTree (string_ident, 0 - unused 2nd parameter);
Notes Can also be used to generate "balanced" tree strings, i.e. reroot a tree in such a way as to balance the number of nodes in each subtree. The latter functionality is useful for speeding up calculations on unrooted trees.

'branch_name' must be a valid tip or internal node name (a string), obtained by a call to 'TipName' or 'BranchName'. The call makes sense if the original tree was rooted.

"string_ident" must be a valid Newick tree string.

Examples
Tree tr = (((a,b),c,d);
newTr = RerootTree (tr, "b");

Result: (b,((c,d),a));

unbalanced_tree = "(1,(2,(3,(4,(5,(6,7))))))"; rebalanced_tree = RerootTree (unbalanced_tree,0);

// rebalanced_tree is now "((5,(6,7)),(1,(2,(3,4))))"

 Last modified: 8/20/2002

 
Sergei L. Kosakovsky Pond and Spencer V. Muse, 1997-2002