我在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"
Run Code Online (Sandbox Code Playgroud)
有没有办法强制它到一个静态布局?
定义节点的顺序确实会对布局产生影响.
如果要保留布局并仅更改节点的颜色,则需要保持节点(首先)外观的顺序,并仅更改其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";
}
Run Code Online (Sandbox Code Playgroud)
导致
您可以使用该指令指定默认属性node [fillcolor = grey]
,并在需要时覆盖特定节点上的默认值(12 [fillcolor = palegreen]
).