GraphViz-当主图从上到下时,如何使子图从左到右? [英] GraphViz - How to have a subgraph be left-to-right when main graph is top-to-bottom?

查看:92
本文介绍了GraphViz-当主图从上到下时,如何使子图从左到右?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的图形文件:

I have a graph file like this:

digraph {
    "Step1" -> "Step2" -> "Step3";

    subgraph step2detail {
        "Step2" -> "note1";
        "Step2" -> "note2";
        "Step2" -> "note3";
        "Step2" -> "note4";
        rankdir=TB
   }
}

我希望子图step2detail悬挂在"Step2"的右侧.

I want the subgraph step2detail to hang off to the right of 'Step2'.

现在看起来像这样:

我希望Step1,Step2和Step3都垂直向下并排成一列.

I want Step1, Step2 and Step3 to all be vertically under each other and in 1 column.

推荐答案

获取您描述的图形的技巧是使用两个子图形并将一个子图形链接到另一个子图形.细节"中不可见的边缘使音符保持对齐.

The trick to get the graph you described is to use two subgraphs and link from one to the other. The invisible edges in "details" are what keep the notes aligned.

digraph {
    rankdir="LR";

    subgraph steps {
        rank="same";
        "Step1" -> "Step2" -> "Step3";
    }

    subgraph details {
        rank="same";
        edge[style="invisible",dir="none"];
        "note1" -> "note2" -> "note3" -> "note4";
    }

    "Step2" -> "note1";
    "Step2" -> "note2";
    "Step2" -> "note3";
    "Step2" -> "note4";
}

结果是:

这篇关于GraphViz-当主图从上到下时,如何使子图从左到右?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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