Graphviz ---如何使边缘不相互交叉;选择自循环边缘位置

时间:2012-10-15 13:24:14

标签: graphviz

我有以下dotfile:

digraph finite_state_machine {                                                                                                                                                                                  
    pad=0.2;
    {
        rank=same;
        node [shape = doublecircle]; q_3;
        node [shape = circle];
        q_1 [ label = <<b><i>q<sub>1</sub></i></b>> ];
        q_2 [ label = <<b><i>q<sub>2</sub></i></b>> ];
        q_3 [ label = <<b><i>q<sub>3</sub></i></b>> ];
        q_1 -> q_1 [ label = <<b><i>^a</i></b>> ];
        q_1 -> q_2 [ label = <<b><i>a</i></b>> ];
        q_2 -> q_2 [ label = <<b><i>^b</i></b>> ];
        q_2 -> q_3 [ label = <<b><i>b</i></b>> ];
    }
}

我得到以下输出:output image

我希望自循环位于节点之上,而不是越过其他边。并且,如果可能的话,更多循环循环。我怎样才能做到这一点?

我希望它看起来像这样:

1 个答案:

答案 0 :(得分:14)

您可以使用ports/compass points

q_1:e -> q_1:w [ label = <<b><i>^a</i></b>> ];
q_2:e -> q_2:w [ label = <<b><i>^b</i></b>> ];

graphviz with loopy loops

或使用nw / ne作为罗盘点:

Event loopier loops