OmniGraffle and Graphviz

I’m using OmniGraffle 4 Professional and lately I’ve been getting a lot of mileage out of a feature that i don’t see discussed very much on the OmniGraffle Users Mailing List. It’s great for getting certain kinds of tree-like diagrams jumpstarted.

I do a lot of flow diagrams or relationship diagrams where I’m depicting how things interact with each other. I use OmniGraffle’s compatibility with graphviz to draw these tree-like diagrams. Here’s a quick summary of what I do. If you follow along (it’s EASY), you’ll see how easily you can get complex trees built quickly. Then once the tree is built, you can use OmniGraffle to beautify it.

Step 1: Create a plain text file in “dot” format.

Use TextEdit, Aquamacs, SubEthaEdit, or whatever to create the file. It’s name should end in .dot, even though that’s what Word uses for document templates. Here’s some sample contents.

digraph "g" {
    // look ma! Comments!
    Paco -> List;
    List -> LotsOfPeople;
    LotsOfPeople -> List;
    List -> Archives;
}

See how intuitive the relationships are? Want a line from A to B and a line from B to A? Just put A->B and B->A in there. Want a single double-headed line? Read the graphviz documentation on the “dot” tool. Or, wait until you get this into OmniGraffle, and then fix it.

Step 2: Import into OmniGraffle Pro

All you do is open the file. Since the file is named .dot, OmniGraffle will show it as one of the kinds of files it knows how to deal with.

The first layout you see in OmniGraffle Pro probably isn’t the best, unless you have a really small graph. But wait, it gets cooler!

Step 3: Let OmniGraffle do some cool arrangement of your graph

Open the Automatic Layout Inspector and start clicking. 🙂 It has a variety of different layout methods that will either make a hierarchy (like a family tree or organization chart), or a more amorphous “gravity”-based layout. I think this is where OmniGraffle really shines and beats graphviz. The graphviz guys who did so much hard work in the first place get a lot of credit. But OmniGraffle Pro totally takes it to the next layout with all the auto layout stuff plus all the knobs I get to tweak. The example graphic on this page comes from a program I helped write that generates random, fictitious family trees.

I put in a good chunk of my family tree this way, and OmniGraffle did a pretty decent job of laying it out. I find myself writing programs that spit out the ‘dot’ format files, and then I open them in OmniGraffle Pro and clean them up. I analyze software this way sometimes.