Skip to content

implement multi child tree#28

Open
sunyiwei24601 wants to merge 4 commits into
parrt:masterfrom
sunyiwei24601:feat_multi_child_tree
Open

implement multi child tree#28
sunyiwei24601 wants to merge 4 commits into
parrt:masterfrom
sunyiwei24601:feat_multi_child_tree

Conversation

@sunyiwei24601

Copy link
Copy Markdown

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.

Comment thread .gitignore Outdated
@parrt

parrt commented Jan 1, 2022

Copy link
Copy Markdown
Owner

interesting...let me try it on a bunch of existing stuff.

@parrt

parrt commented Jan 1, 2022

Copy link
Copy Markdown
Owner

Hiya. What about trees with children fields, which I think is more common than left, mid, right or whatever?

@sunyiwei24601

Copy link
Copy Markdown
Author

Hiya. What about trees with children fields, which I think is more common than left, 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.

@sunyiwei24601

sunyiwei24601 commented Jan 12, 2022

Copy link
Copy Markdown
Author

@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.

@parrt

parrt commented Jan 12, 2022

Copy link
Copy Markdown
Owner

Hi sorry for delay. I just started a new job and will be in a bootcamp for a couple of weeks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants