Can DOT produce a more structured graph?

Deadly 提交于 2019-12-02 04:18:15

You can experiment with splines=ortho graph attibute. It makes the very straight connections with 90 degree angles.

But I won't recommend it. It's almost impossible to control them, port specification often doesn't work with them, and also, ortho splines may eat up some of the edge lables.

Possible solution would be using dummy nodes with point shape (this shape is convenient because it removes node lable by default) and width=0. Use these dummy nodes in places where the 90 degree turn is needed. You will have to group them with main nodes in subgraphs and add rank=same attribute to force these nodes to stay at the same level.

You would probably also need to add weight to some edges to prevent them from being bent (edges with higher weight tend to be straight).

Example

I've implemented part of your example graph using mentioned techniques, the code and image are below:

digraph {
    rankdir=LR
    ranksep=1
    nodesep=0.5

    LOT1 [shape=rect]
    LOT2 [shape=rect]
    LOT3 [shape=rect]
    LOT4 [shape=rect]
    LOT5 [shape=rect]

    {rank=same
        PO
        dot1 [shape=point width=0]
        dot2 [shape=point width=0]
        PO -> dot1 -> dot2 [arrowhead=none]
    }
    dot1 -> WO1 [weight=20]
    {
        rank=same
        WO1
        dot21  [shape=point width=0]
        dot22  [shape=point width=0]
        WO1 -> dot21 -> dot22 [arrowhead=none]
    }
    dot21 -> LOT1 [weight=20]
    dot22 -> LOT2 [weight=20]
    {
        rank=same
        dot31 [shape=point width=0]
        dot32 [shape=point width=0]
        dot33 [shape=point width=0]
        dot31 -> dot32 -> dot33 [arrowhead=none]
    }
        dot2 -> WO2 [weight=20]
    {
        WO2
        rank=same
        dot23 [shape=point width=0]
        dot24 [shape=point width=0]
        dot25 [shape=point width=0]
        WO2 -> dot23 -> dot24 -> dot25 [arrowhead=none]
    }
    dot23 -> LOT3 [weight=20]
    dot24 -> LOT4 [weight=20]
    dot25 -> LOT5 [weight=20]
    dot31 -> SO1
    dot33 -> SO2
    LOT1 -> dot32
}

Result:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!