Graphviz边缘变得疯狂

问题描述 投票:1回答:1

我想像这样绘制马尔可夫链:enter image description here

所以我试着使用这段代码:

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

但这给了我那个结果:enter image description here

那就是问题所在?为什么graphviz不想只是在底部展开图片?

附:我添加了graph [ranksep=5;]属性,它产生了我:enter image description here。现在如何把这条线放在底部?

graphviz dot
1个回答
0
投票

不像第一张图片那样整洁,但你可以试试这个:

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]

}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.