Search code examples
graphvizdot

Graphviz: how to set 'default' arrow style?


Consider this dot language code:

digraph graphname {
    subgraph clusterA {
        node [shape=plaintext,style=filled];
        1 -> 2 [arrowhead=normal,arrowtail=dot];
        2 -> 3 -> X2 -> 5;
        6;
        7;
        label = "A";
        color=blue
    }
}

In the above example, only the 1 -> 2 connection will have the arrowhead=normal,arrowtail=dot style applied; all the other arrows will be of the "default" style.

My question is - how do I set the arrow style (for the entire subgraph - or for the entire graph), without having to copy paste "[arrowhead=normal,arrowtail=dot];" next to each edge connection?

EDIT: Just for reference - the answer from Jesse didn't contain any code; I wrote that snippet and had it in this space here - for unknown reasons, a moderator cut it off from here and pasted it into Jesse's answer.


Solution

  • Use the edge attribute statement, as stated in the DOT Language documentation.

    digraph graphname {
        subgraph clusterA {
            node [shape=plaintext,style=filled];
            edge [arrowhead=normal,arrowtail=dot];
            1 -> 2 ;
            2 -> 3 -> X2 -> 5;
            6;
            7;
            label = "A";
            color=blue
        }
    }