Are there any python libraries for data trees?
I mean a tree as a general data structure, not just an xml tree. (Like in this question, but in python.)
treelib is created to provide an efficient implementation of tree data structure in Python. The main features of treelib includes: Efficient operation of node searching, O(1). Support common tree operations like traversing, insertion, deletion, node moving, shallow/deep copying, subtree cutting etc.
To insert into a tree we use the same node class created above and add a insert class to it. The insert class compares the value of the node to the parent node and decides to add it as a left node or a right node. Finally the PrintTree class is used to print the tree.
I'm happy with treelib. It addresses my problem. Could use a bit more documentation though. But the code is clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With