Python Forum

Full Version: PyEDA-IPython Problem [Graph]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I'm using ipython for drawing binary decision diagrams but i have a problem.

I'm trying to have a graphical model of this:

In [1]: %load_ext gvmagic

In [2]: import pyeda

In [3]: from pyeda.inter import *

In [4]: a, b, c = map(bddvar, 'abc')

In [5]: f = a & b | a & c | b & c

In [6]: %dotobj f

In [7]: f.to_dot()

Out[7]: 'graph BDD { n140390891948072 [label=0,shape=box]; n140390892027576 [label=1,shape=box]; n140390840874880 [label="c",shape=circle]; n140390840893680 [label="b",shape=circle]; n140390840906304 [label="b",shape=circle]; n140390840906248 [label="a",shape=circle]; n140390840874880 -- n140390891948072 [label=0,style=dashed]; n140390840874880 -- n140390892027576 [label=1]; n140390840893680 -- n140390891948072 [label=0,style=dashed]; n140390840893680 -- n140390840874880 [label=1]; n140390840906304 -- n140390840874880 [label=0,style=dashed]; n140390840906304 -- n140390892027576 [label=1]; n140390840906248 -- n140390840893680 [label=0,style=dashed]; n140390840906248 -- n140390840906304 [label=1]; }'
this is the example that is available in pyeda documentation, but i didn't see any way to importing this code to jpg/png files!

anyone can help me?
Apparently my graph is now made, but how do I see it? There are no instructions for that on the website
what you get is representation of the graph in DOT language. It looks like there is a program GraphViz
http://graphviz.org/
that can generate visual representation of the graph from it
some reference:
https://graphs.grevian.org/
http://www.graphviz.org/pdf/dotguide.pdf
http://tonyballantyne.com/graphs.html

There are plenty more...

But if you want to keep it strictly python - there are python packages to work with
https://pypi.org/project/graphviz/
https://pypi.org/project/pydot/

here are google results
https://www.google.com/search?q=generate...and+python
Thanks for your answer,
i already install the GraphViz.
but i don't know how to see the generated graph!
what you have so far is not the graph. it's not generated yet. It is just a description of the graph in DOT language. You need to use this description AND GraphViz to generate/render the graph as a file. I have provided plenty of links to resources that you can use...
(Jun-01-2018, 06:58 PM)buran Wrote: [ -> ]what you have so far is not the graph. it's not generated yet. It is just a description of the graph in DOT language. You need to use this description AND GraphViz to generate/render the graph as a file. I have provided plenty of links to resources that you can use...

Thanks, I will check the links and resources completely and will inform the result to help other people with the same problem Wink
note also the Resources page on GraphViz site. There is section Language Bindings
http://graphviz.org/resources/
there are more python packages than I posted