Created
February 3, 2014 21:52
-
-
Save chaliy/8793186 to your computer and use it in GitHub Desktop.
Algorithm course has trees encoded as array, simple routine to draw grapth from it
This file contains 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
import pydot | |
def print_tree(tree): | |
g1 = pydot.Dot(graph_type='graph') | |
for i in range(len(tree)): | |
g1.add_edge(pydot.Edge(i, tree[i])) | |
g1.write_png('print_tree.png') | |
# Usage | |
# print_tree([6,2,6,4,6,6,6,2,4,4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment