from binarytree import build
inp = [4, 2, 5, 1, 3, None, 6]
root = build(inp)
I have the above code in Jupyter Notebook. I can either print the root or just type root in a cells and they both give different outputs:
If I go to PyCharm, I cannot get the "image" as in Jupyter Notebook. So I would like to ask how does Jupyter Notebook handle the output from root to produce a "image" and how can I replicate it in PyCharm ?
Thanks very much.
CodePudding user response:
As you can find in the documentation for binary tree it uses graphviz for displaying graphs in jupyter notebooks. So to emulate the same results you can install graphviz
and then do something like
from binarytree import build
inp = [4, 2, 5, 1, 3, None, 6]
root = build(inp)
graph = root.graphviz ()
graph.format = 'png'
graph.render ('output', view=True)
to display the graph as an image using your system image viewer