graphviz - Dot language with concentrate=true confusing the graph -


i draw simple graph shown below , found different behavior of color display.

digraph g {      concentrate=true     edge [dir=none]       -> b [color=red]      b -> c         c -> b       b ->      } 

correct image of graph

graph show edge between , b red >> 1 correct.

but when change

     digraph g {      concentrate=true     edge [dir=none]       -> b       b -> c         c -> b       b -> [color=red]     } 

red color not show

this time color of edge , b black not red color want. figure out wrong here?

analysis

because code in question draws 2 edges 1 on top of other, color of last edge drawn wins. layout engine dot works either bottom top or right left. means last edge drawn first 1 listed.

general solution

dot draws digraphs. undirected graph can simulated using dir=none there should 1 edge:

digraph g {   concentrate=true   edge [dir=none]   -> b [color=red]   b -> c  } 

digraph showing sue of dir=none property

alternative

keep in mind dir=none not intended display property. if goal 2 directed edges, dir=both better alternative:

digraph g {   concentrate=true   edge [dir=both]   -> b [color="red:black"]   b -> c [color="black:black] } 

digraph showing use of dir=both attribute

notes

it useful conceptually separate modeling graph display properties. dot doesn't make particularly easy because encourages inlining style information. price of separating concerns pays off in debugging time.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -