我正在尝试创建一个图表,我明确指定了许多节点的排名并指定了集群。以下代码生成我想要的图形类型:
digraph {
rankdir=LR
subgraph cluster0 {
"MATH 208"
"MATH 211"
graph [rankdir=LR, style="rounded,filled", color=gray]
}
subgraph year1 {
subgraph {
"MATH 100"
"MATH 110"
graph [rankdir=LR, rank=same]
}
subgraph {
"MATH 101"
"MATH 211"
"MATH 208"
graph [rankdir=LR, rank=same]
}
graph [rankdir=LR]
}
subgraph year2 {
subgraph {
"MATH 205"
"PHIL 203"
graph [rankdir=LR, rank=same]
}
graph [rankdir=LR]
}
subgraph year3 {
subgraph {
"MATH 311"
"MATH 312"
"MATH 375"
graph [rankdir=LR, rank=same]
}
graph [rankdir=LR]
}
subgraph year4 {
subgraph {
"MATH 447"
"MATH 412"
graph [rankdir=LR, rank=same]
}
graph [rankdir=LR]
}
"MATH 100" -> "MATH 101"
"MATH 100" -> "MATH 208"
"MATH 101" -> "MATH 205"
"MATH 110" -> "MATH 311"
"MATH 211" -> "MATH 311"
"MATH 110" -> "MATH 312"
"MATH 211" -> "MATH 312"
"PHIL 203" -> "MATH 375"
"MATH 110" -> "MATH 447"
"MATH 211" -> "MATH 447"
"MATH 311" -> "MATH 412"
"MATH 312" -> "MATH 412"
}
这会生成一个正确的图形,其中“MATH 211”与“MATH 101”的排名相同,但graphviz会发出警告
Warning: MATH 208 was already in a rankset, ignored in cluster pruned
Warning: MATH 211 was already in a rankset, ignored in cluster pruned
如果我从year1子图中删除“MATH 211”和“MATH 208”,则graphviz不再抱怨,但结果图不再具有与“MATH 101”相同等级的群集(为什么会......) :
有没有办法重新排列/重新排序我的点文件以生成第一张图但没有任何警告?或者指定某个群集应与另一个节点位于同一等级?
我应该注意到这个图形成功地用graphviz 2.26编译,但是用graphviz 2.28失败了......
答案 0 :(得分:0)
一些想法
这是一个适合我的版本:
digraph {
rankdir=LR
subgraph cluster0 {
"MATH 208"
"MATH 211"
graph [style="rounded,filled", color=gray]
}
subgraph clusteryear1 {
subgraph cluster100{
"MATH 100"
"MATH 110"
graph [rank=same]
}
subgraph cluster101{
"MATH 101"
"MATH 211"
"MATH 208"
graph [rank=same]
}
}
subgraph clusteryear2 {
subgraph cluster205{
"MATH 205"
"PHIL 203"
graph [rank=same]
}
}
subgraph clusteryear3 {
subgraph cluster311{
"MATH 311"
"MATH 312"
"MATH 375"
graph [rank=same]
}
}
subgraph clusteryear4 {
subgraph cluster447 {
"MATH 447"
"MATH 412"
graph [rank=same]
}
}
"MATH 100" -> "MATH 101"
"MATH 100" -> "MATH 208"
"MATH 101" -> "MATH 205"
"MATH 110" -> "MATH 311"
"MATH 211" -> "MATH 311"
"MATH 110" -> "MATH 312"
"MATH 211" -> "MATH 312"
"PHIL 203" -> "MATH 375"
"MATH 110" -> "MATH 447"
"MATH 211" -> "MATH 447"
"MATH 311" -> "MATH 412"
"MATH 312" -> "MATH 412"
}