Skip to content

Instantly share code, notes, and snippets.

@titouanc
Created March 28, 2013 10:40
Show Gist options
  • Select an option

  • Save titouanc/5262277 to your computer and use it in GitHub Desktop.

Select an option

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