Skip to content
Graphviz (DOT) templates

Petri Net — Producer-Consumer

Classical Petri net with places, transitions and tokens.

Template previewGraphviz (DOT)
Rendering…

Make it your own.

digraph pn {
  rankdir=LR;
  graph [bgcolor=transparent];
  node [fontname=Inter, fontsize=10];

  // Places (circles)
  P1 [shape=circle, label="P1\n● ●", fillcolor="#dbeafe", style=filled];
  P2 [shape=circle, label="buf\n●",  fillcolor="#dbeafe", style=filled];
  P3 [shape=circle, label="P3\n●",   fillcolor="#dbeafe", style=filled];

  // Transitions (bars)
  T1 [shape=rect, label="produce", style=filled, fillcolor="#fef3c7", height=0.6, width=0.2];
  T2 [shape=rect, label="consume", style=filled, fillcolor="#fef3c7", height=0.6, width=0.2];

  P1 -> T1; T1 -> P2; T1 -> P1;
  P2 -> T2; T2 -> P3; P3 -> T2;
}