GraphViz-子图的对齐 [英] GraphViz - alignment of subgraph

查看:368
本文介绍了GraphViz-子图的对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个这样的图。

I'd like to draw a diagram like this.

我可以画的是:

But the only diagram I can draw is:

我使用的代码:

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

如何绘制所需的图?

推荐答案

您的第一步要使用 rank = same 隐形边缘 constraint = false

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;
}




  • 强制执行(同一组)节点的垂直对齐。

  • rank = same 使节点保持相同

  • 不可见的边缘会强制垂直组内的排名。

  • constraint = false 删除某些边的约束计算。

  • dir = back 反转显示的边方向。

    • 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.
    • 这篇关于GraphViz-子图的对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆