caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
800 stars 185 forks source link

change the keys in _nodes #226

Open Freakwill opened 2 months ago

Freakwill commented 2 months ago

Let nodes of tree be {(k,):Node(identifier=(k,))}, k=1,2,3...

I want to transform it to a new tree with nodes {(0,k):Node(identifier=(0,k))}, k=1,2,3...

What should I do?

The problem is from the case when I paste a new_tree to a tree, with duplicated nid. What I want is that, when I set identifier of a node, the key (nid) of the node in the tree can be changed automatically, meanwhile the _predecessor and _successors of the neighbors of the node also should be changed.