GraphViz - alignment of subgraph

旧城冷巷雨未停 提交于 2019-12-04 06:13:49

A first step in what you want to achieve, using rank=same, invisible edges, groups, and 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).
  • rank=same makes nodes stay on the same rank.
  • Invisible edges enforce rank order within a vertical group.
  • constraint=false removes constraint calculation for some edges.
  • dir=back reverses displayed edge direction.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!