Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement multi child tree #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sunyiwei24601
Copy link

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.

.gitignore Outdated Show resolved Hide resolved
@parrt
Copy link
Owner

parrt commented Jan 1, 2022

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

@parrt
Copy link
Owner

parrt commented Jan 1, 2022

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

@sunyiwei24601
Copy link
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
Copy link
Author

sunyiwei24601 commented Jan 12, 2022

@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
Copy link
Owner

parrt commented Jan 12, 2022

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.

None yet

2 participants