[英]GraphViz - alignment of subgraph
I'd like to draw a diagram like this. 我想画一个这样的图。
But the only diagram I can draw is: 但我能画出的唯一图表是:
The code I used : 我用过的代码:
graph [rankdir = LR]
node [shape=box]
x1;x2;x3;y1;y2;y3;y4;y5;y6;y7;y8;
node [shape=oval]
ind60;dem60;dem65
{x1,x2,x3} -> ind60[arrowhead=none arrowtail=normal dir=both]
{y1,y2,y3,y4} -> dem60[arrowhead=none arrowtail=normal dir=both]
dem65 -> {y5,y6,y7,y8}
ind60->dem60 dem60->dem65 ind60->dem65
How can I draw the desired plot? 我怎样画出想要的情节?
A first step in what you want to achieve, using rank=same
, invisible edges , groups , and constraint=false
: 使用
rank=same
, 不可见边 , 组和constraint=false
第一步:
digraph {
node [shape=box]
{
rank=same;
y1;y2;y3;y4;
}
dem60[shape=oval];
{y1;y2;y3;y4} -> dem60 [dir=back];
{
rank=same;
x2 [group=left];
ind60[shape=oval];
dem65[shape=oval];
y6 [group=right];
x2 -> ind60 [dir=back];
ind60 -> dem65
dem65 -> y6;
}
// Invisible edges to order vertically node groups
edge[style=invis];
x1[group=left];
x3[group=left];
x1 -> x2 -> x3;
node[group=right];
y5 -> y6 -> y7 -> y8;
node[group=""]
edge[style=solid]
ind60->dem60
dem60->dem65
edge[constraint=false];
ind60 -> x1;
ind60 -> x3;
dem65 -> y5;
dem65 -> y7;
dem65 -> y8;
}
group
enforces vertical alignement of nodes (of the same group). group
强制执行垂直对齐节点(同一组)。 rank=same
makes nodes stay on the same rank. rank=same
使节点保持相同的等级。 constraint=false
removes constraint calculation for some edges. constraint=false
删除某些边的约束计算。 dir=back
reverses displayed edge direction. dir=back
反转显示的边缘方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.