【问题标题】:How to prevent the subgraph cluster alignment order from being reversed?如何防止子图簇对齐顺序颠倒?
【发布时间】:2017-10-04 16:35:46
【问题描述】:

如果我有这样的graphviz dot 脚本:

digraph g {
node [style=rounded, shape=box]

    subgraph cluster1 {
        style="invis"
        1 -> 2 -> 3 -> 4 -> 5
    }

    subgraph cluster2 {
        style="invis"
         6 -> 7

         7 -> 8 -> 11
         7 -> 9 -> 11
         7 -> 10 -> 11
    }

    edge[constraint=false];
    splines="ortho"
    5 -> 6 [weight=0]
}

我得到一个看起来像这样的输出(我想要的):

但是,如果末尾的某些节点中的标签变得太长,则排列会像这样颠倒:

digraph g {
node [style=rounded, shape=box]

8 [label="very long label"]
9 [label="very long label"]
10 [label="very long label"]


    subgraph cluster1 {
        style="invis"
        1 -> 2 -> 3 -> 4 -> 5
    }

    subgraph cluster2 {
        style="invis"
         6 -> 7

         7 -> 8 -> 11
         7 -> 9 -> 11
         7 -> 10 -> 11
    }

    edge[constraint=false];
    splines="ortho"
    5 -> 6 [weight=0]
}

如何防止这种情况并强制发生原始排序方法?

【问题讨论】:

    标签: graphviz dot


    【解决方案1】:

    您必须在定义另一个长标签后定义您的长标签; graphviz 按定义的顺序绘制节点。

    digraph g {
    node [style=rounded, shape=box]
    
        subgraph cluster1 {
            style="invis"
            1 -> 2 -> 3 -> 4 -> 5
        }
    
        subgraph cluster2 {
            style="invis"
             6 -> 7
    
             7 -> 8 -> 11
             7 -> 9 -> 11
             7 -> 10 -> 11
        }
    
        8 [label="very long label"]
        9 [label="very long label"]
        10 [label="very long label"]
    
        edge[constraint=false];
        splines="ortho"
        5 -> 6 [weight=0]
    }
    

    产量

    【讨论】:

    • 非常感谢,以所需的出现顺序声明节点使我的所有图表现在都更容易操作,很好的建议!
    猜你喜欢
    • 2012-12-08
    • 2022-11-16
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 2022-12-28
    • 1970-01-01
    • 2015-06-21
    • 1970-01-01
    相关资源
    最近更新 更多