lolviz
lolviz copied to clipboard
implement multi child tree
Hi, I was looking for a package to visualize Tree Search Algorithm Recently and I found this repository and really liked it. But for tree visualization, the treeviz
function can only support binary tree with child name left
and right
.
So I made some modification to support multi children and specifying child name. I add 2 new parameters for treeviz()
, childfields
and show_all_children
. The variable name in childfields will be recognized as child node. And if show_all_children=False
, it will only visualize the child names exist, else it will show all the names in childfieds
.
I know you may be busy and this repository hasn't been updated for a long time. You can check these modification anytime free. I am so glad to receive any suggestions from you.
interesting...let me try it on a bunch of existing stuff.
Hiya. What about trees with children
fields, which I think is more common than left
, mid
, right
or whatever?
Hiya. What about trees with
children
fields, which I think is more common thanleft
,mid
,right
or whatever?
Yes, I did consider such implementation before. If I didn't misunderstand you, you mean such a structure of trees:
class Tree:
def __init__(self, **children):
self.children = children
My current implementation can not handle such situations. I would like to add a new parameter for treeviz()
function called dict_children_fields=("children")
. For a field in this tuple (if its type is dictionary), we will recognize every key of this dict as a child which need to be visualized.
But the treeviz
function may be too complicated due to too many specified parameters. If you have other plans, I'm glad to hear them.
@parrt Hi, I just push my new implementation. You can check it out while free.
To visualize trees with children
fields, I create a new function treeplusviz
(maybe it's not a good name haha), which will regard each in children field as a child of parent tree node.
Hi sorry for delay. I just started a new job and will be in a bootcamp for a couple of weeks!