简体   繁体   English

GraphViz - 子图的对齐

[英]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使节点保持相同的等级。
  • Invisible edges enforce rank order within a vertical group. 不可见边缘在垂直组内强制执行排名顺序。
  • 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM