💾 Archived View for tilde.club › ~filip › tech › cheatsheet › dot › dot.gmi captured on 2024-08-31 at 12:22:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
DOT is a graph description language. There are several programs that can be used to render, view, and manipulate graphs in the DOT language, most notable of which is Graphviz <1>.
The following example illustrates the basic syntax of DOT.
digraph example { charset="UTF-8" // default charset node [shape=box] // default node style newrank="true" // new ranking algorithm rankdir="LR" // rank direction: TB (default), BT, LR, RL compound="true" // allows edges between clusters with lhead and ltail a1 [label="A1"]; a2 [label="A2"]; subgraph cluster_b { label="A cluster of Bs"; color=purple; rank="same"; /* rank constraints on the nodes in a subgraph: "same" - all nodes are placed on the same rank "min" - all nodes are placed on the minimum rank */ b1 [label="B1", shape=diamond, color=white, style=filled, fillcolor=blue]; b2 [label="B2", shape=doubleoctagon, color=white, style=filled, fillcolor=red]; b3 [label="B3", shape=hexagon, color=white, style=filled, fillcolor=green]; b1 -> {b2 b3} [arrowhead=diamond]; } subgraph cluster_c { label="Some structures"; node [shape=record]; c1 [label="<f0> left|<f1> middle|<f2> right"]; c2 [label="<f0> one|<f1> two"]; c3 [label="X|{a |{b|<important> c|d}| e}| X | Y"]; c1:f1 -> c2:f0; c1:f2 -> c3:important; } a1 -> b1 [arrowhead=dot, label="1?"]; a2 -> b2 [arrowhead=inv, label="2?", lhead="cluster_b"]; b2 -> c1 [arrowhead=vee, ltail="cluster_b", lhead="cluster_c"]; }