开发者

Same nodes, different colerings in Graphviz

I have a simple directed graph in Graphviz with two kinds of nodes and edges. E开发者_JAVA技巧ach kind has it's own color. My problem is, that I would like to keep how the graph is drawn, but just change the colors. However, when I swap the node names within the two node definitions, the graph changes its layout.

node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen] 3 "4-5" 7 "8-9" 10 18 19
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = grey]  11 12 "13-14"

Is there a way to force it to one static layout?


The order in which the nodes are defined does have an impact on the layout.

If you want to keep the layout and change only the colors of the nodes, then you'll need to keep the order of (first) appearance of the nodes and only change their fillcolor attribute.

For example:

digraph g {
  node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen];
  3;
  "4-5";
  7;
  "8-9";
  10 [fillcolor = grey];
  18;
  19;
  // new default fillcolor
  node [fillcolor = grey];
  11;
  12 [fillcolor = palegreen];
  "13-14";
}

Resulting in

Same nodes, different colerings in Graphviz

You can specify the default attributes using the node [fillcolor = grey] instruction, and override the default values on a specific node if needed (12 [fillcolor = palegreen]).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜