Examples borrowed from this GraphViz Pocket Reference and its underlying Git repository.
1 2 3 4 5 6 7 8 9 10 11 12 |
[graphviz lang="circo" href="self" output="svg" class="example1"] graph { rankdir = LR; a -- b; b -- c; a -- c; d -- c; e -- c; e -- a; } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[graphviz lang="circo" href="self" output="svg" class="example2"] graph { a -- b; b -- c; c -- d; d -- e; e -- f; a -- f; a -- c; a -- d; a -- e; b -- d; b -- e; b -- f; c -- e; c -- f; d -- f; } [/graphviz] |
1 2 3 4 5 6 7 8 |
[graphviz output="svg" class="example3"] digraph { a -> b; b -> c; c -> d; d -> a; } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 |
[graphviz lang="circo" href="self" output="svg" class="example4"] digraph { a -> b[label="0.2",weight="0.2"]; a -> c[label="0.4",weight="0.4"]; c -> b[label="0.6",weight="0.6"]; c -> e[label="0.6",weight="0.6"]; e -> e[label="0.1",weight="0.1"]; e -> b[label="0.7",weight="0.7"]; } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 11 12 |
[graphviz lang="circo" href="self" output="svg" class="example5"] graph { a -- b[color=red,penwidth=3.0]; b -- c; c -- d[color=red,penwidth=3.0]; d -- e; e -- f; a -- d; b -- d[color=red,penwidth=3.0]; c -- f[color=red,penwidth=3.0]; } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 11 |
[graphviz lang="circo" href="self" output="svg" class="example6a"] digraph { subgraph cluster_0 { label="Subgraph A"; a -> b; b -> c; c -> d; } subgraph cluster_1 { label="Subgraph B"; a -> f; f -> c; } } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 |
[graphviz lang="circo" href="self" output="svg" class="example6b"] graph { splines=line; subgraph cluster_0 { label="Subgraph A"; a; b; c } subgraph cluster_1 { label="Subgraph B"; d; e; } a -- e; a -- d; b -- d; b -- e; c -- d; c -- e; } [/graphviz] |
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 |
[graphviz lang="dot" href="self" output="svg" class="example7a"] graph { rankdir=LR; // Left to Right, instead of Top to Bottom a -- { b c d }; b -- { c e }; c -- { e f }; d -- { f g }; e -- h; f -- { h i j g }; g -- k; h -- { o l }; i -- { l m j }; j -- { m n k }; k -- { n r }; l -- { o m }; m -- { o p n }; n -- { q r }; o -- { s p }; p -- { s t q }; q -- { t r }; r -- t; s -- z; t -- z; } [/graphviz] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[graphviz lang="dot" href="self" output="svg" class="example7b"] graph { rankdir=LR; a -- { b c d }; b -- { c e }; c -- { e f }; d -- { f g }; e -- h; f -- { h i j g }; g -- k; h -- { o l }; i -- { l m j }; j -- { m n k }; k -- { n r }; l -- { o m }; m -- { o p n }; n -- { q r }; o -- { s p }; p -- { s t q }; q -- { t r }; r -- t; s -- z; t -- z; { rank=same; b, c, d } { rank=same; e, f, g } { rank=same; h, i, j, k } { rank=same; l, m, n } { rank=same; o, p, q, r } { rank=same; s, t } } [/graphviz] |