31

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

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

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

我希望子图 step2detail 挂在“Step2”的右侧。

现在它看起来像这样:

在此处输入图像描述

我希望 Step1、Step2 和 Step3 都在彼此垂直的下方和 1 列中。

4

5 回答 5

19

获取您描述的图表的技巧是使用两个子图并从一个链接到另一个。“细节”中不可见的边缘是保持音符对齐的原因。

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

结果是:

在此处输入图像描述

于 2010-08-31T13:40:20.863 回答
8

这很简单 - 只需使用group属性让 graphviz 更喜欢直边:

digraph {
    node[group=a, fontname="Arial", fontsize=14];
    "Step1" -> "Step2" -> "Step3";

    node[group=""];
    "Step2" -> "note1";
    "Step2" -> "note2";
    "Step2" -> "note3";
    "Step2" -> "note4";
}

图形输出

于 2011-11-15T20:09:15.470 回答
7

通过将 Step 节点分组为一个聚集子图,输出如下:

digraph {
    subgraph cluster_0 {
        color=invis;
        "Step1" -> "Step2" -> "Step3";
    }

    subgraph cluster_1 {
        color=invis;
        "Step2" -> "note4";
        "Step2" -> "note3";
        "Step2" -> "note2";
        "Step2" -> "note1";
   }
}

color=invis删除否则将在集群周围绘制的边框

于 2009-12-10T05:56:59.990 回答
2

rankdir 不能直接在子图中工作,但如果你添加另一组花括号 - 不管它叫什么 - rankdir 工作:

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

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

在此处输入图像描述

于 2019-04-26T17:35:28.733 回答
-4

使用命令:rankdir=LR;

digraph {
rankdir=LR;

    "Step1" -> "Step2" -> "Step3";

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

}
于 2010-01-16T17:54:28.347 回答