2014-03-29 55 views
2

我正在使用graphviz/dot來生成一個圖。級聯或繼承Graphviz中多個節點聲明的屬性

我想將圖中的節點和/或邊組合成語義類,每個類都有一組類似於CSS的級聯或繼承的節點和/或邊緣屬性。但是,如果將單個節點分組到多個類中,則後面的屬性聲明將覆蓋較早的屬性聲明,即使該屬性未在稍後的聲明中指定。特別是,它會將值恢復爲默認/更高範圍的值。

例如:

node [shape="hexagon", style="filled", fillcolor="lightskyblue1"]; 
{ node [shape="box"]; a; b; } 
{ node [fillcolor="red"]; b; c; } 

我想要什麼:

a [shape="box", style="filled", fillcolor="lightskyblue1"]; 
b [shape="box", style="filled", fillcolor="red"]; 
c [shape="hexagon", style="filled", fillcolor="red"]; 

我能得到什麼:

a [shape="box", style="filled", fillcolor="lightskyblue1"]; 
b [shape="hexagon", style="filled", fillcolor="red"]; 
c [shape="hexagon", style="filled", fillcolor="red"]; 

這可能嗎?

回答

0

不同的結果在這裏。

a [shape="box", style="filled", fillcolor="lightskyblue1"]; 
b [shape="box", style="filled", fillcolor="lightskyblue1"]; 
c [shape="hexagon", style="filled", fillcolor="red"]; 

這看起來對我來說是正確的。對象繼承定義(=第一次出現)時的默認屬性。 b的定義與[shape="box"]一致。 fillcolor="lightskyblue1"從外部作用域起作用。

http://www.graphviz.org/content/dot-language(由我高亮):

如果默認屬性使用節點,邊或圖形語句定義,或由一個屬性分配未連接到的節點或邊緣,的任何對象定義的適當類型之後將繼承此屬性值。

graphviz version 2.38.0