Created
March 28, 2013 10:40
-
-
Save titouanc/5262277 to your computer and use it in GitHub Desktop.
Afficher facilement les arbres binaires des exercices du 5ème chapitre de TP d'INFO-F-103 à l'ULB
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 node2dot(tree): | |
| if tree.left: | |
| print('\t', tree.getRootVal(), '->', tree.left.getRootVal()) | |
| node2dot(tree.left) | |
| if tree.right: | |
| print('\t', tree.getRootVal(), '->', tree.right.getRootVal()) | |
| node2dot(tree.right) | |
| def tree2dot(tree, title='Arbre'): | |
| print('digraph ', title, '{') | |
| node2dot(tree) | |
| print('}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment