用点绘制工作分解结构(WBS)

时间:2017-09-10 15:14:18

标签: graph graphviz dot

我想用点语言绘制WBS。

我有几个问题:

  • 更改排名方向(第一级从上到下,其他级别从左到右)。
  • 链接两个以上节点的一条边

我试过了:

digraph A {
    rankdir = TB;
    graph [splines=ortho]
    node [shape=box]
    edge [dir=none]

    node [label="1 Widget Mgmt. System"] 1
    node [label="1.1 Initiation"] 1.1
    node [label="1.1.1 Evaluation"] "1.1.1"
    node [label="1.2 Planning"] 1.2
    node [label="1.2.1"] "1.2.1"
    node [label="1.2.1.1"] "1.2.1.1"
    node [label="1.2.1.2"] "1.2.1.2"
    node [label="1.2.2"] "1.2.2"

    1 -> {1.1, 1.2}
    1.2 -> {"1.2.1", "1.2.2"}
    "1.2.1" -> {"1.2.1.1", "1.2.1.2"}
}

enter image description here

这是我想要的结果: WBS example

1 个答案:

答案 0 :(得分:0)

下图显示了使用群集和隐藏节点进行对齐的想法。

digraph A {
    newrank=true;
    graph [splines=ortho];
    node [shape=box];
    edge [dir=none];
    style=invis;//Comment this line to see the ideas of using clusters

    1 -> {11 12 13};

    subgraph cluster_11 {
        11 -> {111 112 113 114};
        {
            node [style=invis];
            edge [style=invis];
            subgraph cluster_C11_lvl_1 {
                C11->111->112->113->114;
            }
            {rank=same 11 C11}
        }
    }

    subgraph cluster_12 {
        12 -> {121 122};
        121 -> {1211 1212};
        122 -> {1221 1222};
        {
            node [style=invis];
            edge [style=invis];
            subgraph cluster_C12_lvl_1 {
                C12->121->122;
            }
            subgraph cluster_C12_lvl_2 {
                C121->1211->1212->C122->1221->1222;
            }
            {rank=same 12 C12}
            {rank=same 121 C121}
            {rank=same 122 C122}
        }
    }

    subgraph cluster_13 {
        13 -> {131 132 133}
        {
            node [style=invis];
            edge [style=invis];
            subgraph cluster_C13_lvl_1 {
                C13->131->132->133;
            }
            {rank=same 13 C13}
        }
    }
}

它给出了以下结果:

enter image description here