从graphviz中的多个节点声明级联或继承属性

时间:2014-03-29 20:16:12

标签: graphviz dot

我正在使用graphviz / dot生成图表。

我想将图中的节点和/或边缘分组为语义类,每个类都有一组类似于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"];

这可能吗?

1 个答案:

答案 0 :(得分: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版本2.38.0