Tarlison Sander
Tarlison Sander

Reputation: 60

How does the insertion of nodes in a tree work using the treelib library in python?

how are you guys?
I'm having doubts with a python library, called treelib. I noticed that when using the 'tree.show ()' function it returns the tree with the children sorted in alphabetical order and this raised the question of how the insertion in this library works. I went to their source code, but as I'm starting in python I didn't understand how the insertion of the node in the tree worked ... So, someone who uses this library knows how to inform me if in an insert like the one below:

tree.create ("E", 1)
tree.create ("A", 2, parent = 1)
tree.create ("B", 3, parent = 1)

Who will be the son to the left of E? and who will be the son on the right?

Upvotes: 2

Views: 736

Answers (1)

Tom Gebel
Tom Gebel

Reputation: 805

According to the documentation, your tree should look like this:

E
├── A
└── B

Upvotes: 2

Related Questions