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:
![](https://static.wixstatic.com/media/c57328_c7494d39691a4dfdb2b4f30e15946c7c~mv2.png/v1/fill/w_117,h_135,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/c57328_c7494d39691a4dfdb2b4f30e15946c7c~mv2.png)
We can make various forms of customization, as I've done in the following monstrous BDD:
![](https://static.wixstatic.com/media/c57328_ffa2242e241445e6a093e335e612d9cd~mv2.png/v1/fill/w_49,h_57,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/c57328_ffa2242e241445e6a093e335e612d9cd~mv2.png)
Isn't that beautiful?!