Graphviz中的非确定性结果(点)

时间:2018-03-14 11:02:10

标签: graphviz dot

如何强制graphviz始终生成相同的布局?

给出一个图表:

digraph {
    subgraph clusterA {
        subgraph clusterB {
            "B.001"
            "B.002"
            "B.003"
            "B.004"
        }
        subgraph clusterC {
            "C.001"
            "C.002"
            "C.003"
        }
    }
    subgraph clusterD {
        subgraph clusterE {
            "E.001"
        }
        subgraph clusterF {
            "F.001"
            "F.002"
            "F.003"
        }
        subgraph clusterG {
            "G.001"
            "G.002"
        }
    }
    subgraph clusterH {
        "H.001"
    }
    "G.002" -> "F.003"
    "F.001" -> "C.003"
    "G.002" -> "F.002"
    "G.002" -> "D.001"
}

当我将其传递给dot时,它有时会生成具有以下布局的结果: nice result

有时喜欢这个: ugly result

显然第一个看起来好多了,我希望graphviz坚持这个。

我尝试将图表传递到fdpunflatten,但它不会改变任何内容。

1 个答案:

答案 0 :(得分:0)

我尝试了很多不同的在线渲染解决方案和cli。我看不到另一个输出然后你的第二个。但如果您更喜欢第一个,只需切换ClusterB和ClusterC的顺序。

digraph {
rankdir=TB
subgraph clusterA {

    subgraph clusterC {
        "C.001"
        "C.002"
        "C.003"
    }

    subgraph clusterB {
        "B.001"
        "B.002"
        "B.003"
        "B.004"
    }

}

subgraph clusterD {
    subgraph clusterE {
        "E.001"
    }
    subgraph clusterF {
        "F.001"
        "F.002"
        "F.003"
    }
    subgraph clusterG {
        "G.001"
        "G.002"
    }
}

subgraph clusterH {
    "H.001"
}


"G.002" -> "F.003"
"F.001" -> "C.003"
"G.002" -> "F.002"
"G.002" -> "D.001"

}

enter image description here