原则上有三种可能性:
- 在创建节点之前设置默认属性:
- 全局范围内 - 对所有后续的节点创建有效
- 在子图中局部范围内 - 仅对子图内的节点创建有效
- 使用显式属性创建节点
- 在创建后将属性分配给一组节点。
选项1和2仅允许每个节点一个组,因为创建是单个事件。选项3允许每个赋值不同的分组。
在创建节点之前全局设置默认属性
digraph {
x // node with current defaults
// set default
node [shape=box color=red]
// create with default values
a1, a2
// set default
node [shape=circle color=blue]
// create with default values
b1, b2
y // node with current defaults
x->{a1 a2}
a1->{b1 b2}
a2->{b1 b2}
{b1,b2}->y
}
在创建节点之前本地设置默认属性
digraph {
x
{
node [shape=box color=red]
a1, a2
}
{
node [shape=circle color=blue]
b1, b2
}
y
x->{a1 a2}
a1->{b1 b2}
a2->{b1 b2}
{b1,b2}->y
}
![在这里输入图片描述](https://istack.dev59.com/Qha3g.webp)
创建带有显式属性的节点
digraph {
x
a1, a2 [shape=box color=red]
b1, b2 [shape=circle color=blue]
y
x->{a1 a2}
a1->{b1 b2}
a2->{b1 b2}
{b1,b2}->y
}
创建后给一组节点分配属性
digraph {
x // node with current defaults
// create with default values
a1, a2, b1, b2
// assign shape
a1, a2 [shape=box]
b1, b2 [shape=circle]
// assign color
a1, b2 [color=red]
b1, a2 [color=blue]
y // node with current defaults
x->{a1 a2}
a1->{b1 b2}
a2->{b1 b2}
{b1,b2}->y
}
![在此输入图片描述](https://istack.dev59.com/m0eMs.webp)
a1, a2 [atrrbuites...]
对应的点语言语法? - sify