FSM Diagrams in LaTeX

I’ve written several times about my use and affection for finite state automata in programming. It’s amazing how often it can reduce a complex problem to a triviality. The first stage in taking advantage of this method is to draw a state transition diagram. Once you’ve got the diagram, it’s easy to write the code.

After writing the code, you’ll want to document the program and that will include the state diagram. Traditionally, I’ve used the Graphviz dot program to produce these diagrams but it can also be done directly from LaTeX.

Alexander Hayes has a short post that shows how to use LaTeX to generate FSM diagrams. It’s not a comprehensive tutorial, although he does give a link to one, but it’s still useful for getting an idea of how to produce such diagrams.

Documentation is always a pain, of course, so it’s nice to discover tools that make it easier. Even if you usually write in, say, Org mode, you can still include the requisite LaTeX for the diagrams or you can generate them separately and include the generated diagram in your text.

The nice thing about this solution is that it uses easily available, open source tools that most developers are going to have installed anyway. If you use state diagrams and have to document them, take a look at Hayes’ post.

This entry was posted in General and tagged . Bookmark the permalink.