Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graphviz: direction of edges in terms of color

Hi
Can I get graphviz to color the edges in a way that identifies the direction? For example, the part of the edge near its source node might be blue and then it gradually shades away to red as it nears the target node. Or are there any other graphing tools (like graphviz) that can do this?

Any help in this regard would be much appreciated.

like image 755
Puneet Avatar asked Nov 22 '10 23:11

Puneet


1 Answers

Well, i don't know anything about your current dot file, so i'll have to make a couple of assumptions. To deal with the easy case first, distinguishing the the direction of an edge is the job of the arrowhead (points to) and arrowtail (points from). Your graph is only going to render those if your graph type is a directed graph, which you set at the top of your dot file, e.g.,

digraph G {
    node[style=filled, color=cornflowerblue, fontcolor=white, fontsize=10, 
          fontname='Helvetica']
    edge[arrowhead=vee, arrowtail=inv, arrowsize=.7, color=maroon, fontsize=10,
          fontcolor=navy]

    a1 -> a2;
    a2 -> a4 [taillabel="TL     "];
    a2 -> a5 [headlabel="       HL"];
    a4 -> a6 [label="  ordinary edge label"]
}

If you've already crated a directed graph but for some reason you want an additional indicator to show edge direction, then the only relevant edge attributes i can think of are the headlabel and taillabel attributes, which allows you to specify which end of an edge a label is placed. The small dot file above will render this graph:

alt text

like image 158
doug Avatar answered Sep 24 '22 22:09

doug