A simple code that draws your multivalued/binary decision diagrams.
Today some students in my class told me they are spending a lot of time manually drawing BDDs when they want to test their understanding of more complicated instances. So here comes graphviz! The Python code is pretty simple (so is in C++ and Java). You just need to install graphviz, create a Digraph, add the arcs and associate a style to them based on their type (0-arc or 1-arc). Here is the documented code that includes a simple example:
And here is the result, a non-reduced BDD:

We can make various forms of customization, as I've done in the following monstrous BDD:

Isn't that beautiful?!
Comments