xflr6 / graphviz

Simple Python interface for Graphviz
https://graphviz.readthedocs.io
MIT License
1.65k stars 213 forks source link

graphiz.Source and graphiz object are giving two different structures. #134

Closed ninjakx closed 3 years ago

ninjakx commented 3 years ago
from graphviz import Graph, Source
g = Graph('G', filename='process.gv', engine='sfdp')

g.edge('run', 'intr')
g.edge('intr', 'runbl')
g.edge('runbl', 'run')
g.edge('run', 'kernel')
g.edge('kernel', 'zombie')
g.edge('kernel', 'sleep')
g.edge('kernel', 'runmem')
g.edge('sleep', 'swap')
g.edge('swap', 'runswap')
g.edge('runswap', 'new')
g.edge('runswap', 'runmem')
g.edge('new', 'runmem')
g.edge('sleep', 'runmem')
g

s1

Source(g)

s2

Using Source graph more look like a tree.

xflr6 commented 3 years ago

The example uses engine='sfdp', so you need to set the same engine if you want to reproduce with Source :

>>> Source(g, engine='sfdp')

See also graphviz-engines.ipynb and manual.html#engines.