How can I draw a graph with Graphviz and annotate its nodes and edges?
For example:
(a: level=0) --3--> (b: level=1)
(a: level=0) --2--> (c: level=1)
It is quite simple, here's a dot
file for your example (test.dot
):
strict digraph {
1 [label="a: level=0"];
2 [label="b: level=1"];
3 [label="c: level=1"];
1 -> 2 [label="3"];
1 -> 3 [label="2"];
}
which with dot -Tpng -o test.png test.dot
will output:
There are way more parameters you can set to get the layout that you want. I suggest you look through the Graphviz documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With