You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wish to swap the tree.root with the new_root Node but I am stuck. Is there a function that I am missing that may be of help to me? Or any suggestions? Thank you in advance
def SwapRoots(tree,new_root):
n_subtrees = list()
new_tree = Tree()
new_tree.add_node(new_root)
for child in tree.children(tree.root):
n_subtrees.append(tree.subtree(child.identifier))
for subtree in n_subtrees:
subtree.show()
new_tree.paste(new_root.identifier,subtree)
new_tree.show()
return new_tree
Ι have written the aforementioned piece of code but is there a more efficient way to do it?
The text was updated successfully, but these errors were encountered:
Good evening everyone. I would like some assistance on a specific matter of treelib's tree.
Lets assume that I am having the following code:
I wish to swap the tree.root with the new_root Node but I am stuck. Is there a function that I am missing that may be of help to me? Or any suggestions? Thank you in advance
Ι have written the aforementioned piece of code but is there a more efficient way to do it?
The text was updated successfully, but these errors were encountered: