Skip to main content

Posts

Showing posts with the label Graphviz

DOT Language with Graphviz to render in Pyhton

Graphviz gives two main classes Digraph and Graph that create undirected and directed graphs respectively. They can be rendered and displayed directly inside a notebook. The default formate is PDF in the rendering. See Graphviz Doc . Graph and Digraph objects have a _repr_mimebundle_() method so they can be rendered and displayed directly inside a Jupyter notebook. For an example, check the examples/graphviz-notebook.ipynb file in the source repository/distribution (or the same notebook in nbviewer). import graphviz g = graphviz.Digraph('G', filename='hello.gv') g.edge('Hello', 'World') g Check the generated DOT source code. print(g.source) # digraph G { # Hello -> World # } To use a different output file format you can use the format argument when creating your Graph or Digraph object, or change the format attribute on an existing graph object . When you need a image in 'png', set format='png' or use attribute as g.f...