Codders, resources for programmers by Vokimon

Generating UML Use Cases Diagrams with GraphViz Dot

In my opinion using a tool like GraphViz's dot to generate UML Use Case Diagrams can be more productive and task centered than doing it with graphical tools.

Doing Use Case Diagrams with Dot is much like doing documents in LaTeX: You need a well crafted document scheletton and then you can only center yourself in the content. You have nearly no control over the layout, but layout on UML diagrams is like a hell and Dot does such a good work that i don't want to get bothered with that.

The example on the right has been generating taking this sample (colorized version) and placing this actor image on the same directory while running:

$ dot -Tpng MarUseCases.dot -o MarUseCases.png

If you look at the sample code, you will see that is very straight forward to add Actors, Use Cases and Use/Includes/Extends/Generalizes relations. Because this is what you will do most the time.

It is also very easy to change the look and feel (fonts, colors...). Most can be deduced from the sample but you may want to take a look at the dot manual.

I'm a newbie to dot and there are a lot of things to enhance. For example, the PS output does not generate actors labels. I tried with this encapsulated postcript Actor shape but then the actor label dissapeared. Also the hack to place the actors labels at the bottom of the actors is a kludge (but it works!). Maybe it would be better to add an 'actor' shape to dot. Any way it is good enough for me to use. I hope it would also for you. Please let me know if you do any improvements on the template.