Graphviz Graphiz边缘变得疯狂

Graphviz Graphiz边缘变得疯狂,graphviz,dot,Graphviz,Dot,我想画这样的马尔可夫链: 所以我尝试使用以下代码: digraph { center=true rankdir=TB; node [ shape = circle, width=0.3 ]; S0:ne -> S1:nw [xlabel="9Z"] S1:ne -> S2:nw [xlabel="8Z"] S2:ne -> S3:nw [xlabel="7Z"] S3:ne -> S4:nw [xlabel="6

我想画这样的马尔可夫链:

所以我尝试使用以下代码:

digraph 
{
    center=true
    rankdir=TB;
    node [ shape = circle, width=0.3 ];

    S0:ne -> S1:nw [xlabel="9Z"]
    S1:ne -> S2:nw [xlabel="8Z"]
    S2:ne -> S3:nw [xlabel="7Z"]
    S3:ne -> S4:nw [xlabel="6Z"]
    S4:ne -> S5:nw [xlabel="5Z"]
    S5:ne -> S6:nw [xlabel="4Z"]
    S6:ne -> S7:nw [xlabel="3Z"]
    S7:ne -> S8:nw [xlabel="2Z"]
    S8:ne -> S9:nw [xlabel="1Z"]

    S1:sw -> S0:se [xlabel="M"]
    S2:sw -> S0:se [xlabel="M"]
    S3:sw -> S0:se [xlabel="M"]
    S4:sw -> S0:se [xlabel="M"]
    S5:sw -> S0:se [xlabel="M"]
    S6:sw -> S0:se [xlabel="M"]
    S7:sw -> S1:se [xlabel="M"]
    S8:sw -> S2:se [xlabel="M"]
    S9:sw -> S3:se [xlabel="M"]


    {rank = same; S0; S1; S2; S3; S4; S5; S6; S7; S8; S9;}
}
但这给了我一个结果:

这就是问题所在?为什么graphviz不想只扩展底部的图片


另外,我添加了
graph[ranksep=5;]
属性,它生成了以下内容:。现在如何将这些线放在底部?

不像第一张图片上那样整齐,但您可以尝试以下方法:

digraph
{   graph [ranksep=0.4 nodesep=0.1]
    node [ shape = circle, width=0.3];
    edge [arrowsize=0.7]
    rankdir=LR;

    S0:e -> S1:w [weight=2 style=invis]
    S1:e -> S2:w [weight=2 style=invis]
    S2:e -> S3:w [weight=2 style=invis]
    S3:e -> S4:w [weight=2 style=invis]
    S4:e -> S5:w [weight=2 style=invis]
    S5:e -> S6:w [weight=2 style=invis]
    S6:e -> S7:w [weight=2 style=invis]
    S7:e -> S8:w [weight=2 style=invis]
    S8:e -> S9:w [weight=2]

    S0:n -> S1:nw [xlabel="9Z"]
    S1:n -> S2:nw [xlabel="8Z"]
    S2:n -> S3:nw [xlabel="7Z"]
    S3:n -> S4:nw [xlabel="6Z"]
    S4:n -> S5:nw [xlabel="5Z"]
    S5:n -> S6:nw [xlabel="4Z"]
    S6:n -> S7:nw [xlabel="3Z"]
    S7:n -> S8:nw [xlabel="2Z"]
    S8:n -> S9:nw [xlabel="1Z"]

    S0:se -> S1:s [dir=back xlabel="M" constraint=false]
    S0:se -> S2:s [dir=back xlabel="M" constraint=false]
    S0:se -> S3:s [dir=back xlabel="M" constraint=false]
    S0:se -> S4:s [dir=back xlabel="M" constraint=false]
    S0:se -> S5:s [dir=back xlabel="M" constraint=false]
    S0:se -> S6:s [dir=back xlabel="M" constraint=false]
    S1:se -> S7:s [dir=back xlabel="M" constraint=false]
    S2:se -> S8:s [dir=back xlabel="M" constraint=false]
    S3:se -> S9:s [dir=back xlabel="M" constraint=false]

}

没有第一张图像那么整洁,但您可以尝试以下方法:

digraph
{   graph [ranksep=0.4 nodesep=0.1]
    node [ shape = circle, width=0.3];
    edge [arrowsize=0.7]
    rankdir=LR;

    S0:e -> S1:w [weight=2 style=invis]
    S1:e -> S2:w [weight=2 style=invis]
    S2:e -> S3:w [weight=2 style=invis]
    S3:e -> S4:w [weight=2 style=invis]
    S4:e -> S5:w [weight=2 style=invis]
    S5:e -> S6:w [weight=2 style=invis]
    S6:e -> S7:w [weight=2 style=invis]
    S7:e -> S8:w [weight=2 style=invis]
    S8:e -> S9:w [weight=2]

    S0:n -> S1:nw [xlabel="9Z"]
    S1:n -> S2:nw [xlabel="8Z"]
    S2:n -> S3:nw [xlabel="7Z"]
    S3:n -> S4:nw [xlabel="6Z"]
    S4:n -> S5:nw [xlabel="5Z"]
    S5:n -> S6:nw [xlabel="4Z"]
    S6:n -> S7:nw [xlabel="3Z"]
    S7:n -> S8:nw [xlabel="2Z"]
    S8:n -> S9:nw [xlabel="1Z"]

    S0:se -> S1:s [dir=back xlabel="M" constraint=false]
    S0:se -> S2:s [dir=back xlabel="M" constraint=false]
    S0:se -> S3:s [dir=back xlabel="M" constraint=false]
    S0:se -> S4:s [dir=back xlabel="M" constraint=false]
    S0:se -> S5:s [dir=back xlabel="M" constraint=false]
    S0:se -> S6:s [dir=back xlabel="M" constraint=false]
    S1:se -> S7:s [dir=back xlabel="M" constraint=false]
    S2:se -> S8:s [dir=back xlabel="M" constraint=false]
    S3:se -> S9:s [dir=back xlabel="M" constraint=false]

}