Drawing trees in Python

I wrote code for a binary tree, I was looking for methods for visualizing it in windows, and as graphs, with nodes and other things, I did not find a decent answer, I turn to the guru of this forum for help, namely for advice on where it is better to make trees in Python, and graph-like ones.

Author: antipups, 2019-09-30

2 answers

To visualize any graphs (not large volumes), you can use Graphviz. For python, there is an API graphviz, through which you can set and draw a graph. It is also possible to draw binary trees using this tool, by default they are not very beautiful, but it is possible to write a script to graphviz that will make the display of binary trees correct.

 2
Author: nikialeksey, 2019-10-01 06:57:45

Yes, you can use Graphviz to build trees and display a picture of this where you need to, for this you need to download Graphviz itself from the official website, install it, and write it in a python script import os os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/' instead of my path, specify your path, and write your own algorithm for constructing these trees.

 0
Author: antipups, 2019-10-07 05:26:56