Created
October 17, 2016 17:07
-
-
Save fogonthedowns/7dd65e72c318dc37f6089fb1b0174dbd to your computer and use it in GitHub Desktop.
proper tree parse scipy ClusterNode object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def parse(tree, p): | |
| path = p[:] | |
| path.append(str(tree.get_id())) | |
| if tree.is_leaf(): | |
| print('.'.join(path)) | |
| else: | |
| #Here I assume get_left() returns some falsey value for no left child | |
| left = tree.get_left() | |
| if left: | |
| parse(left, path) | |
| right = tree.get_right() | |
| if right: | |
| parse(right, path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment