Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graphviz defining more "defaults"

Tags:

graphviz

Need draw a complex graph where will be 3 types of edges, and several predefined node-types.

Is possible somewhat define more (e.g. not only one default) "edge type" (or node-type) for the later use?

mean something like:

edge [colorscheme=paired12, color=8, fontsize=11, fontname="Arial narrow"];
edge2 [colorscheme=paired12, color=3, fontsize=11, fontname="Arial narrow", style=bold];
edge3 [colorscheme=paired12, color=5, fontsize=14, fontname="Arial narrow"];

node1 -> node2; /* will use the default edge definition from the above */
node2 -> node3 [edgetype=edge2]; /* will use the second edge definition */
node2 -> node4 [edgetype=edge3]; /* and so on... */

The above, ofc, is not correct - only for explanation...

like image 208
jm666 Avatar asked Nov 19 '11 16:11

jm666


1 Answers

Using gvpr is simple, if you figure out the basics:

input.dot

digraph test {
    node1 -> node2[label="test 1"]; /* will use the default edge definition from the above */
    node2 -> node3 [label="test 2", edgetype="edge2"]; /* will use the second edge definition */
    node2 -> node4 [label="test 3", edgetype="edge3"]; /* and so on... */
}

filter.gvpr

E {
    color="red";
    fontsize=11;
    fontname="Arial narrow"
}
E[edgetype == "edge2"] {
    color="green";
    fontsize=11;
    fontname="Arial narrow";
    style="bold"
}
E[edgetype == "edge3"] {
    color="blue";
    fontsize=14;
    fontname="Arial narrow"
}

With command

gvpr -c -f filter.gvpr -o output.dot input.dot

will produce the output.dot file:

digraph test {
    node1 -> node2   [color=red,
        fontname="Arial narrow",
        fontsize=11,
        label="test 1"];
    node2 -> node3   [color=green,
        edgetype=edge2,
        fontname="Arial narrow",
        fontsize=11,
        label="test 2",
        style=bold];
    node2 -> node4   [color=blue,
        edgetype=edge3,
        fontname="Arial narrow",
        fontsize=14,
        label="test 3"];
}
like image 113
Nepomuk Frädrich Avatar answered Oct 27 '22 00:10

Nepomuk Frädrich