aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/dot.md
blob: dc706e326ad100af3f46cb5b13b195d0c8189b6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# dot(1)

[Online playground](https://edotor.net/)

## Example `dot` file to copy & paste from.

Can be rendered to `svg` with the following command.
```bash
dot -T svg -o g.svg g.dot
```

Example `dot` file.
```dot
// file: g.dot
digraph {
    // Render ranks from left to right.
    rankdir=LR
    // Make background transparent.
    bgcolor=transparent

    // Global node attributes.
    node [shape=box]
    // Global edge attributes.
    edge [style=dotted,color=red]

    // Add nodes & edge.
    stage1 -> stage2
    // Add multiple edges at once.
    stage2 -> { stage3_1, stage3_2 }
    // Add edge with custom attributes.
    stage3_2 -> stage4 [label="some text"]

    // Set custom attributes for specific node.
    stage4 [color=green,fillcolor=lightgray,style="filled,dashed",label="s4"]

    // Create a subgraph. This can be used to group nodes/edges or as scope for
    // global node/edge attributes.
    // If the name starts with 'cluster' a border is drawn.
    subgraph cluster_1 {
        stage5_1
        stage5_2
    }

    // Add some edges to subgraph nodes.
    stage3_1 -> { stage5_1, stage5_2 }
}
```

Rendered `svg` file.
![g.svg](assets/g.svg)

## References
- [DOT language](https://graphviz.org/doc/info/lang.html)
- [Attributes](https://graphviz.org/doc/info/attrs.html)
- [Node shapes](https://graphviz.org/doc/info/shapes.html)
- [Colors](https://graphviz.org/doc/info/colors.html)
- [User manual](https://graphviz.org/pdf/dotguide.pdf)