如何在 graphviz 中设置三车道 layout/ranking?
How do I set a three lane layout/ranking in graphviz?
我必须每周多次创建流程图。我研究了 graphviz 以减少这个过程的麻烦。我刚开始学习它,它真的很棒。但是,我不知道如何使用子图来创建我想要的布局。
- 我想要一个带有流程图的“通道”/“行”
- 我想要一个带有注释的“车道”/“行”,该步骤在
时刻
- 我想要一个“车道”/“行”,其中包含有关
进程
我尝试摆弄子图,但那没有用。有什么办法可以做到这一点?这是示例代码。我还添加了一张图片来说明我想要实现的目标:
digraph{
graph[rankdir =LR]
// the steps
subgraph steps{
node[shape = box]
S_1[label="Step 1"];
S_2[label = "Step 2"];
S_3[label = "Step ..."];
S_4[label = "Step k"]
S_1 -> S_2 -> S_3 -> S_4;
}
// the problems
subgraph problem {
node[shape = box, color = "red",fontsize = 8]
S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
S_3p[label = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]
S_1p->S_1 //argh
S_3p -> S_3 //argh
}
//the notes
subgraph notes{
node[shape = plaintext, color = "black",fontsize = 8]
S_1n[label="This is really important additional information"]
S_3n[label="This one as well"]
S_1n -> S_1;
S_3n -> S_3;
}
}
- 子图和簇子图很容易混淆。请参阅 https://www.graphviz.org/pdf/dotguide.pdf
的第 3.2 节
- 没有直接的方法来排序或调整簇的大小,您需要不可见的节点和边。痛
- 这个结果是~接近,但紫色边缘不是最理想的! (在我看来)。 Dot 努力不在节点或其他结构的顶部绘制边。对不起。
// graph[rankdir =LR] << use default TB
graph [newrank=true] // dang, does not help the curvy edges
// the steps
subgraph cluster_steps{
{
rank=same // keep horizontal
node[shape = box]
S_1[label="Step 1"];
S_2[label = "Step 2"];
S_3[label = "Step ..."];
S_4[label = "Step k"]
invisA[shape=point style=invis group=I]
invisA -> S_1 [style=invis]
//edge [constraint=false]
S_1 -> S_2 -> S_3 -> S_4;
}
}
// the problems
subgraph cluster_problem {
{
rank=same // keep horizontal
node[shape = box, color = "red",fontsize = 8]
S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
S_3p[label = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]
invisB[shape=point style=invis group=I]
invisB-> S_1p [style=invis]
edge [constraint=false color=red]
S_1p->S_1 //argh << pirate talk??
S_3p -> S_3 //argh
}
}
//the notes
subgraph cluster_notes{
{
rank=same // keep horizontal
node[shape = plaintext, color = "black",fontsize = 8]
S_1n[label="This is really important additional information"]
S_3n[label="This one as well"]
invisC[shape=point style=invis group=I]
invisC-> S_1n [style=invis]
edge [constraint=false color=purple]
S_1n -> S_1;
S_3n -> S_3;
}
}
edge[style=invis]
invisA -> invisB -> invisC
}
给予:
我必须每周多次创建流程图。我研究了 graphviz 以减少这个过程的麻烦。我刚开始学习它,它真的很棒。但是,我不知道如何使用子图来创建我想要的布局。
- 我想要一个带有流程图的“通道”/“行”
- 我想要一个带有注释的“车道”/“行”,该步骤在 时刻
- 我想要一个“车道”/“行”,其中包含有关 进程
我尝试摆弄子图,但那没有用。有什么办法可以做到这一点?这是示例代码。我还添加了一张图片来说明我想要实现的目标:
digraph{
graph[rankdir =LR]
// the steps
subgraph steps{
node[shape = box]
S_1[label="Step 1"];
S_2[label = "Step 2"];
S_3[label = "Step ..."];
S_4[label = "Step k"]
S_1 -> S_2 -> S_3 -> S_4;
}
// the problems
subgraph problem {
node[shape = box, color = "red",fontsize = 8]
S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
S_3p[label = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]
S_1p->S_1 //argh
S_3p -> S_3 //argh
}
//the notes
subgraph notes{
node[shape = plaintext, color = "black",fontsize = 8]
S_1n[label="This is really important additional information"]
S_3n[label="This one as well"]
S_1n -> S_1;
S_3n -> S_3;
}
}
- 子图和簇子图很容易混淆。请参阅 https://www.graphviz.org/pdf/dotguide.pdf 的第 3.2 节
- 没有直接的方法来排序或调整簇的大小,您需要不可见的节点和边。痛
- 这个结果是~接近,但紫色边缘不是最理想的! (在我看来)。 Dot 努力不在节点或其他结构的顶部绘制边。对不起。
// graph[rankdir =LR] << use default TB
graph [newrank=true] // dang, does not help the curvy edges
// the steps
subgraph cluster_steps{
{
rank=same // keep horizontal
node[shape = box]
S_1[label="Step 1"];
S_2[label = "Step 2"];
S_3[label = "Step ..."];
S_4[label = "Step k"]
invisA[shape=point style=invis group=I]
invisA -> S_1 [style=invis]
//edge [constraint=false]
S_1 -> S_2 -> S_3 -> S_4;
}
}
// the problems
subgraph cluster_problem {
{
rank=same // keep horizontal
node[shape = box, color = "red",fontsize = 8]
S_1p[label= "This is not working\nat all. People simply skip this\nstep."]
S_3p[label = "Instead of changing\nthe session setting,\nusers simply call colleagues via phone"]
invisB[shape=point style=invis group=I]
invisB-> S_1p [style=invis]
edge [constraint=false color=red]
S_1p->S_1 //argh << pirate talk??
S_3p -> S_3 //argh
}
}
//the notes
subgraph cluster_notes{
{
rank=same // keep horizontal
node[shape = plaintext, color = "black",fontsize = 8]
S_1n[label="This is really important additional information"]
S_3n[label="This one as well"]
invisC[shape=point style=invis group=I]
invisC-> S_1n [style=invis]
edge [constraint=false color=purple]
S_1n -> S_1;
S_3n -> S_3;
}
}
edge[style=invis]
invisA -> invisB -> invisC
}
给予: