I’m currently trying to write a paper on quantum Bayesian networks, the structures which gave this blog its name, and which have interested me for a long time. My huge interest in QB nets drove me to write a Mac application called Quantum Fog that implements them. That was more than ten years ago, and since then, I’ve learned a lot more about QB nets, especially about their connection to quantum information theory, which is the reason why I’m trying to write a new paper about them.
Anyhow, I decided that writing such a paper would be much less laborious if I could draw figures of directed graphs directly in LaTex. (quantum as well as classical Bayesian networks are directed acyclic graphs). As usual, the LaTex gods have not disappointed me. It turns out that drawing directed graphs in LaTeX is very easy using XY-pic.
I just love XY-pic and that’s why I’m writing this blog post, to rave about it. XY-pic was written by Kristoffer H. Rose, Ross Moore and collaborators to draw figures of commutative diagrams in category theory. It has also been used very successfully to draw figures in “automata theory, algebra, neural networks, topology (knots and braids), database theory, chemistry, and genealogy”. The very useful and popular package Q-circuit for drawing quantum circuits in LaTex is implemented using XY-pic commands.
For those already familiar with LaTex (one of the most beautiful and useful and influential scientific softwares in the history of mankind, comparable in importance to the invention of the printing press), learning to do basic stuff with XY-pic can be done in a day. The tug (TeX users group) page for XY-pic will lead you to some nice tutorials with examples. You can also do a Google Image search for “xy-pic and latex”, and find examples that way.
If you too need a way of drawing directed graphs in LaTex, and you’ve never used xy-pic before, you may find it useful to see in this blog post a very simple example. Mind you, XY-pic can be used to draw much more sophisticated diagrams, but I hereby present as a simple example, the famous (among Bnet aficionados) Bayesian network called the “Chest Clinic”. The code in this file produced the following figure: