Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Graphviz render State Transition Diagrams like this?

Can Graphviz render State Transition Diagrams exactly like this?

http://upload.wikimedia.org/wikipedia/commons/c/cf/Finite_state_machine_example_with_comments.svg

=== Edit ===

Marapet's code comes really close (see: http://i.imgur.com/ElzSl.png ). I am accepting his answer.

like image 950
Erik Avatar asked Aug 09 '11 09:08

Erik


2 Answers

I'd create nodes for the transition conditions :

digraph g{
  Opened[label="1\nOpened\nE: open door"];
  Closed[label="2\nClosed\nE: closed door"];
  node[shape=plaintext];

  Opened -> close_door[arrowhead=none];
  close_door -> Closed;
  Opened -> open_door[dir=back];
  open_door -> Closed[arrowhead=none];
}
like image 70
marapet Avatar answered Oct 31 '22 21:10

marapet


I would use label on the arrow instead of creating a node for the close_door:

Opened -> Closed [label=close_door];

like image 2
user3498957 Avatar answered Oct 31 '22 21:10

user3498957