Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Graphviz DOT

sirene draws Graphviz DOT graphs as images and as text, with its own layered layout:

digraph classes {
  node [shape=record]
  Animal [label="{Animal|+ name : string\l+ age : int\l|+ die() : void\l}"]
  Dog [label="{Dog|+ bark() : void\l}"]
  Cat [shape=Mrecord, label="{Cat|+ meow() : void}"]
  Dog -> Animal [arrowhead=empty]
  Cat -> Animal [arrowhead=empty]
}
the drawing of the dot source above

A .dot or .gv file, a dot or graphviz block in Markdown, and any source given with --lang dot is DOT; so is stdin or another file that starts with graph, digraph, or strict and then { (after an optional ID). --lang mermaid reads a source as Mermaid instead. Directories are scanned for .dot and .gv files. In the editor a DOT graph is read-only on the drawing side. Only the first graph in a file is drawn.

What is read

SyntaxDrawn as
digraph, graph, strictarrows at heads, no arrows, repeated edges merged
a -> b -> c, a -> {b c}edge chains, and edges to every node in a subgraph
node [...], edge [...]defaults for later statements in the same braces
subgraph cluster_x { ... }a cluster titled by its label, filled by bgcolor; other subgraphs only scope defaults
rankdir, label, bgcolorthe direction, the title, and the background
shapethe nearest sirene shape; record and Mrecord as compartments
stylefilled, rounded (nodes only; clusters stay square, with a warning), dashed, dotted, bold, invis
color, fillcolor, fontcolor, penwidthborder, fill, text color, line width
label, headlabel, taillabellabels, with \n, \l, \N, \G, \E, \T, \H
arrowhead, arrowtail, dir, minlenend markers, which ends have them, and rank span
rank=same, min, max, source, sinknodes sharing a rank, or in the first or last
constraint=false, group, orderingedges that do not rank, straight edges in a group, source order
compound=true with lhead, ltailedges ending at a cluster’s border
a:e, a:p, tailport, headportcompass ports; record ports with rankdir=LR or RL
HTML <TABLE> node labelscompartments, with <HR/> sections and PORT cells

Colors are X11 names, #rrggbb, #rrggbbaa, or H,S,V fractions. See spec/graphviz-dot.md for the full list of shapes and arrows.

Errors

Syntax errors, -> in a graph, -- in a digraph, and subgraphs nested more than 64 deep are errors. An attribute that is not drawn, an unknown shape, color, arrow, or style, and a second graph in a file are warnings, each once.

Not drawn

The layout is sirene’s, not Graphviz’s. Record ports in top-down graphs (the edge joins the node), images, node sizes, fonts, and other engines’ layout attributes (pos, overlap, splines) are warned about and ignored. HTML labels other than node tables are drawn as their text.