2011-08-30 49 views
4

我在Graphviz中有一个简单的有向图,有两种节点和边。每种都有它自己的颜色。我的问题是,我想保留图形的绘制方式,只是改变颜色。但是,当我交换两个节点定义中的节点名称时,该图将更改其布局。相同的节点,在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" 

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

回答

8

order其中定义节点确实会影响布局。

如果要保留布局并仅更改节点的颜色,则需要保留订单(首次)出现节点并仅更改它们的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"; 
} 

fillcolor nodes

所得的,可以指定使用node [fillcolor = grey]指令默认属性,并覆盖默认值一个特定节点,如果上需要(12 [fillcolor = palegreen])。