From 6b252dbc87462a5ccfd31c8fc6c27195646365dd Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sat, 25 Jun 2022 21:52:54 +0200 Subject: [dot]: added copy & paste dot example graph --- src/SUMMARY.md | 1 + src/assets/g.svg | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tools/README.md | 1 + src/tools/dot.md | 54 ++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 src/assets/g.svg create mode 100644 src/tools/dot.md (limited to 'src') diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 97b62dd..8f87671 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -16,6 +16,7 @@ - [radare2](./tools/radare2.md) - [qemu](./tools/qemu.md) - [pacman](./tools/pacman.md) + - [dot](./tools/dot.md) - [Resource analysis & monitor](./monitor/README.md) - [lsof](./monitor/lsof.md) diff --git a/src/assets/g.svg b/src/assets/g.svg new file mode 100644 index 0000000..f66c7b7 --- /dev/null +++ b/src/assets/g.svg @@ -0,0 +1,94 @@ + + + + + + + +cluster_1 + + + + +stage1 + +stage1 + + + +stage2 + +stage2 + + + +stage1->stage2 + + + + + +stage3_1 + +stage3_1 + + + +stage2->stage3_1 + + + + + +stage3_2 + +stage3_2 + + + +stage2->stage3_2 + + + + + +stage5_1 + +stage5_1 + + + +stage3_1->stage5_1 + + + + + +stage5_2 + +stage5_2 + + + +stage3_1->stage5_2 + + + + + +stage4 + +s4 + + + +stage3_2->stage4 + + +some text + + + diff --git a/src/tools/README.md b/src/tools/README.md index 8d3baa6..d6b0a21 100644 --- a/src/tools/README.md +++ b/src/tools/README.md @@ -13,3 +13,4 @@ - [radare2](./radare2.md) - [qemu](./qemu.md) - [pacman](./pacman.md) +- [dot](./dot.md) diff --git a/src/tools/dot.md b/src/tools/dot.md new file mode 100644 index 0000000..d3d7ac8 --- /dev/null +++ b/src/tools/dot.md @@ -0,0 +1,54 @@ +# dot(1) + +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) -- cgit v1.2.3