notes/article/graphviz/dot-example.md

1.2 KiB

Graphviz markdown doc example

basic dot example

digraph example {
    node [shape="diamond"]
    edge [style="dashed"]

    a[style="filled", color="green"]
    b
    c
    d

    a -> b
    b -> d
    c -> d[color="red"]
}

struct example

Not supporting so well

digraph structs {
    node [shape=plaintext]
    struct1 [label=<
        <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
        <TR><TD>left</TD><TD PORT="f1">mid dle</TD><TD PORT="f2">right</TD></TR>
        </TABLE>>];
    struct2 [label=<
        <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
        <TR><TD PORT="f0">one</TD><TD>two</TD></TR>
        </TABLE>>];
    struct3 [label=<
        <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
        <TR>
            <TD ROWSPAN="3">hello<BR/>world</TD>
            <TD COLSPAN="3">b</TD>
            <TD ROWSPAN="3">g</TD>
            <TD ROWSPAN="3">h</TD>
        </TR>
        <TR>
            <TD>c</TD><TD PORT="here">d</TD><TD>e</TD>
        </TR>
        <TR>
            <TD COLSPAN="3">f</TD>
        </TR>
        </TABLE>>];
    struct1:f1 -> struct2:f0;
    struct1:f2 -> struct3:here;
}