Created
February 15, 2019 21:32
-
-
Save kukumber/a77e9fd8e6d820d03741416eddaf0026 to your computer and use it in GitHub Desktop.
Drawing simple tree with pydot.
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 | |
data = [6, 2, 6, 4, 6, 6, 6, 6, 4, 4] | |
graph = pydot.Dot(graph_type="graph") | |
graph.obj_dict['attributes']["size"] = '"10,10!"' | |
graph.obj_dict['attributes']["dpi"] = "144" | |
for k, v in enumerate(data): | |
if k != v: | |
edge = pydot.Edge(v, k) | |
graph.add_edge(edge) | |
else: | |
node = pydot.Node(v) | |
graph.add_node(node) | |
graph.write('test.png', format='png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment