Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Algorithm course has trees encoded as array, simple routine to draw grapth from it
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
You can’t perform that action at this time.