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

Unable to get a nodeID from level data #182

Open Veek opened 3 years ago

Veek commented 3 years ago

_[t.add_node(T.Node(identifier=r(), data=1), parent=t.allnodes()[-1]) for i in range(1,10)]

>  t.show()
> 0
> └── 100
>     ├── 4
>     └── 20
>         ├── 28
>         ├── 77
>         ├── 80
>         ├── 83
>         ├── 84
>         ├── 87
>         │   └── 17
>         └── 98
> 
> max([(t.size(i), i) for i in range(0, t.depth())])
> (7, 3)

So 7 siblings at level 3 BUT how do I now get the nodeID '20' (I need to move 20 and siblings to a new subtree)

(The problem is I have a huge class hierarchy in Libreoffice-API and creating a classic DOT code file will result in endless scrolling in Graphviz. Therefore I need to extract the subtrees with large elements and treat them differently to save space)