4

我在 Graphviz 中有一个简单的有向图,有两种节点和边。每种都有它自己的颜色。我的问题是,我想保留图形的绘制方式,而只是更改颜色。但是,当我在两个节点定义中交换节点名称时,图形会更改其布局。

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"

有没有办法强制它使用一个静态布局?

4

1 回答 1

8

定义节点的顺序确实对布局有影响。

如果要保留布局并仅更改节点的颜色,则需要保持节点(第一次)出现的顺序并仅更改其fillcolor属性。

例如:

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";
}

导致

填充颜​​色节点

您可以使用指令指定默认属性,并在需要时覆盖特定节点上的默认值( )。node [fillcolor = grey]12 [fillcolor = palegreen]

于 2011-08-31T07:58:14.080 回答