fsteeg.com | notes | tags

∞ /notes/uml-class-diagrams-with-graphviz | 2006-11-17 | programming

UML Class Diagrams with GraphViz

Cross-posted to: https://fsteeg.wordpress.com/2006/11/17/uml-class-diagrams-with-graphviz/

Class diagrams can be created with GraphViz quite nicely: hierachical structure, reversed arrows, empty arrowtails and records as node shapes, pretty compliant. Code follows, rendered result below.

Graphviz DOT diagram source (also embedded in HTML source)

digraph hierarchy {
  size="5,5"
  node[shape=record,style=filled,fillcolor=ivory]
  edge[dir=back, arrowtail=empty]

  2[label = "{AbstractSuffixTree|+ text\n+ root|...}"]
  3[label = "{SimpleSuffixTree|...| + constructTree()\l...}"]
  4[label = "{CompactSuffixTree|...| + compactNodes()\l...}"]

  5[label = "{SuffixTreeNode|...|+ addSuffix(...)\l...}"]
  6[label = "{SuffixTreeEdge|...|+ compactLabel(...)\l...}"]

  2->3
  2->4

  5->5[constraint=false, arrowtail=odiamond]
  4->3[constraint=false, arrowtail=odiamond]
  2->5[constraint=false, arrowtail=odiamond]
  5->6[arrowtail=odiamond]
}