ste*_*fan 13
原则上有三种可能性
选项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
}
Run Code Online (Sandbox Code Playgroud)
在创建节点之前在本地设置默认属性
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
}
Run Code Online (Sandbox Code Playgroud)
创建具有显式属性的节点
digraph {
x // node with current defaults
// create with explicit attributes
a1, a2 [shape=box color=red]
// create with explicit attributes
b1, b2 [shape=circle color=blue]
y // node with current defaults
x->{a1 a2}
a1->{b1 b2}
a2->{b1 b2}
{b1,b2}->y
}
Run Code Online (Sandbox Code Playgroud)
在创建后将属性分配给一组节点
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
}
Run Code Online (Sandbox Code Playgroud)
这可以针对具有node
关键字的图中的所有节点完成,或者针对具有关键字的图中的所有边完成edge
。这也可以在逐节点或逐边的基础上完成。
整个图或子图的示例:
digraph
{
subgraph readers
{
node[shape=box; color=red;]
r1; r2; r3;
}
subgraph books
{
node[shape=circle; color=blue;]
b1; b2; b3;
}
r1->{b1 b2}
r2->{b2 b3}
r3->{b1 b2 b3}
}
Run Code Online (Sandbox Code Playgroud)
这会给你图表:
每个节点属性的示例:
digraph
{
n1[shape=triangle];
n2[shape=star];
n3[shape=square];
n1->n2->n3
}
Run Code Online (Sandbox Code Playgroud)
会给图表: