Using a GraphViz (.dot, .gv) file as Model or Implementation

It is possible to use GraphViz graph file as model.

The graph file has to have file name suffix .gv or .dot .

Graph Type

The GraphViz file has to specify a directed graph (digraph).

Indicating the initial state

The initial state has to be indicated by adding an initial transition to the model, as follows

  1. Add an additional state that is invisible.
    The name of that state, _nil in the example below, does not matter (as long as it differs from all other state names in the model).
  2. Add a transition from that added state to the initial state; use an empty string as label on that transition.
    The name of the initial state, start in the example below, does not matter.
_nil            [style="invis"];
_nil -> start   [label=""];

Example

digraph s02 {
    _nil [style="invis"];
    _nil -> start [label=""];
    start -> w [label="W?"];
    start -> z [label="Z?"];
    w -> start [label="L!"];
    z -> start [label="R!"];
    w -> ww [label="W?"];
    w -> wz [label="Z?"];
    z -> zw [label="W?"];
    z -> zz [label="Z?"];
    ww -> w [label="L!"];
    wz -> z [label="L!"];
    zw -> w [label="R!"];
    zz -> z [label="R!"];
}

Back to Usage scenarios