集群中的中心节点
Centers node in a cluster
我尝试在 graphviz 中仅在一张图中绘制多个有限状态图
现在我有这个:
digraph D {
rankdir = LR;
node [shape = circle]
subgraph automaton_1 {
invis [shape = point style = invis]
0 [label =<S<SUB>0</SUB>>]
1 [label =<S<SUB>1</SUB>>]
2 [label =<S<SUB>2</SUB>>]
3 [label =<S<SUB>3</SUB>>]
4 [label =<S<SUB>4</SUB>>]
5 [label =<S<SUB>5</SUB>> peripheries = 2]
}
invis -> 0
0 -> 1[label = "a"]
1 -> 2[label = "b"]
0 -> 3[label = "b"]
3 -> 4[label = "c"]
2 -> 5[label = "d"]
4 -> 5[label = "d"]
subgraph automaton_2 {
b_invis [shape = point style = invis]
b_0 [label =<S<SUB>0</SUB>'>]
b_1 [label =<S<SUB>1</SUB>'>]
b_2 [label =<S<SUB>2</SUB>'>]
b_3 [label =<S<SUB>3</SUB>'>]
b_4 [label =<S<SUB>4</SUB>'>]
b_5 [label =<S<SUB>5</SUB>'> peripheries = 2]
}
b_invis -> b_0
b_0 -> b_1[label = "a"]
b_1 -> b_2[label = "b"]
b_0 -> b_3[label = "b"]
b_3 -> b_4[label = "c"]
b_2 -> b_5[label = "d"]
b_4 -> b_5[label = "d"]
invis -> b_invis[constraint=false, style=invis]
}
结果如下:image 1
但我想要两个独立对齐的图表,对齐方式如下:image 2
您可以通过在名称中添加 cluster_
将您的 subgraph
变成实际的集群。来自每个子图的内部集群节点不会相互影响。
这是更正后的代码和结果(请注意,我还为每个集群添加了 peripheries=0
以删除边框:
digraph D {
rankdir = LR;
node [shape = circle]
subgraph cluster_automaton_1 {
peripheries=0
invis [shape = point style = invis]
0 [label =<S<SUB>0</SUB>>]
1 [label =<S<SUB>1</SUB>>]
2 [label =<S<SUB>2</SUB>>]
3 [label =<S<SUB>3</SUB>>]
4 [label =<S<SUB>4</SUB>>]
5 [label =<S<SUB>5</SUB>> peripheries = 2]
}
invis -> 0
0 -> 1[label = "a"]
1 -> 2[label = "b"]
0 -> 3[label = "b"]
3 -> 4[label = "c"]
2 -> 5[label = "d"]
4 -> 5[label = "d"]
subgraph cluster_automaton_2 {
peripheries=0
b_invis [shape = point style = invis]
b_0 [label =<S<SUB>0</SUB>'>]
b_1 [label =<S<SUB>1</SUB>'>]
b_2 [label =<S<SUB>2</SUB>'>]
b_3 [label =<S<SUB>3</SUB>'>]
b_4 [label =<S<SUB>4</SUB>'>]
b_5 [label =<S<SUB>5</SUB>'> peripheries = 2]
}
b_invis -> b_0
b_0 -> b_1[label = "a"]
b_1 -> b_2[label = "b"]
b_0 -> b_3[label = "b"]
b_3 -> b_4[label = "c"]
b_2 -> b_5[label = "d"]
b_4 -> b_5[label = "d"]
invis -> b_invis[constraint=false, style=invis]
}
我尝试在 graphviz 中仅在一张图中绘制多个有限状态图 现在我有这个:
digraph D {
rankdir = LR;
node [shape = circle]
subgraph automaton_1 {
invis [shape = point style = invis]
0 [label =<S<SUB>0</SUB>>]
1 [label =<S<SUB>1</SUB>>]
2 [label =<S<SUB>2</SUB>>]
3 [label =<S<SUB>3</SUB>>]
4 [label =<S<SUB>4</SUB>>]
5 [label =<S<SUB>5</SUB>> peripheries = 2]
}
invis -> 0
0 -> 1[label = "a"]
1 -> 2[label = "b"]
0 -> 3[label = "b"]
3 -> 4[label = "c"]
2 -> 5[label = "d"]
4 -> 5[label = "d"]
subgraph automaton_2 {
b_invis [shape = point style = invis]
b_0 [label =<S<SUB>0</SUB>'>]
b_1 [label =<S<SUB>1</SUB>'>]
b_2 [label =<S<SUB>2</SUB>'>]
b_3 [label =<S<SUB>3</SUB>'>]
b_4 [label =<S<SUB>4</SUB>'>]
b_5 [label =<S<SUB>5</SUB>'> peripheries = 2]
}
b_invis -> b_0
b_0 -> b_1[label = "a"]
b_1 -> b_2[label = "b"]
b_0 -> b_3[label = "b"]
b_3 -> b_4[label = "c"]
b_2 -> b_5[label = "d"]
b_4 -> b_5[label = "d"]
invis -> b_invis[constraint=false, style=invis]
}
结果如下:image 1
但我想要两个独立对齐的图表,对齐方式如下:image 2
您可以通过在名称中添加 cluster_
将您的 subgraph
变成实际的集群。来自每个子图的内部集群节点不会相互影响。
这是更正后的代码和结果(请注意,我还为每个集群添加了 peripheries=0
以删除边框:
digraph D {
rankdir = LR;
node [shape = circle]
subgraph cluster_automaton_1 {
peripheries=0
invis [shape = point style = invis]
0 [label =<S<SUB>0</SUB>>]
1 [label =<S<SUB>1</SUB>>]
2 [label =<S<SUB>2</SUB>>]
3 [label =<S<SUB>3</SUB>>]
4 [label =<S<SUB>4</SUB>>]
5 [label =<S<SUB>5</SUB>> peripheries = 2]
}
invis -> 0
0 -> 1[label = "a"]
1 -> 2[label = "b"]
0 -> 3[label = "b"]
3 -> 4[label = "c"]
2 -> 5[label = "d"]
4 -> 5[label = "d"]
subgraph cluster_automaton_2 {
peripheries=0
b_invis [shape = point style = invis]
b_0 [label =<S<SUB>0</SUB>'>]
b_1 [label =<S<SUB>1</SUB>'>]
b_2 [label =<S<SUB>2</SUB>'>]
b_3 [label =<S<SUB>3</SUB>'>]
b_4 [label =<S<SUB>4</SUB>'>]
b_5 [label =<S<SUB>5</SUB>'> peripheries = 2]
}
b_invis -> b_0
b_0 -> b_1[label = "a"]
b_1 -> b_2[label = "b"]
b_0 -> b_3[label = "b"]
b_3 -> b_4[label = "c"]
b_2 -> b_5[label = "d"]
b_4 -> b_5[label = "d"]
invis -> b_invis[constraint=false, style=invis]
}