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

how to insert a node in a tree? #197

Closed terry-jt closed 2 years ago

terry-jt commented 2 years ago

What's the simple way to insert a node in a tree? I do not find a direct API. Thanks.

liamlundy commented 2 years ago

In the basic usage section there is an example of how to add a code to the tree: https://treelib.readthedocs.io/en/latest/#basic-usage

If you want to create a node and then add it, you can do the following:

node = Node(identifier=1, tag="One")
tree.add_node(node)

Lmk if you have any other questions or if we can close this issue. Thanks!

liamlundy commented 2 years ago

Closed due to inactivity