alignment - 如何对齐点文件中的子图

标签 alignment graphviz subgraph

我正在尝试使用点文件和 graphviz 对齐三个或更多子图。我认为我的问题最好用几个例子来说明:

我的第一次尝试:

digraph FutopJobFlow {
    rankdir=LR;
    node [shape=box]
    compound=true

    subgraph clusterA {label = " A ";
        A -> a1;
        a1 -> a2;
        a2 -> a3;
    }

    subgraph clusterB {label = " B ";
        B -> b1;
        b1 -> b2;
    }

    subgraph clusterC {label = " C ";
        C -> c1;
        c1 -> c2;
    }
    A -> B [lhead=clusterB];
    B -> C [lhead=clusterC];
    X -> A [lhead=clusterA];
    Y -> B [lhead=clusterB];
    Z -> C [lhead=clusterC];
}

给出这个结果:

First try of aligning subgraphs

这里的各个子图看起来像我想要的,但没有对齐。因此我尝试使用命令等级:

digraph FutopJobFlow {
    rankdir=LR;
    node [shape=box]
    compound=true

    subgraph clusterA {label = " A ";
        A -> a1;
        a1 -> a2;
        a2 -> a3;
    }

    subgraph clusterB {label = " B ";
        B -> b1;
        b1 -> b2;
    }

    subgraph clusterC {label = " C ";
        C -> c1;
        c1 -> c2;
    }

    {rank=same; A; B; C;}

    A -> B [lhead=clusterB];
    B -> C [lhead=clusterC];
    X -> A [lhead=clusterA];
    Y -> B [lhead=clusterB];
    Z -> C [lhead=clusterC];
}

结果如下图: Second try of aligning subgraphs

这里的对齐看起来不错,但现在“A”、“B”和“C”不再位于子图中!

我尝试了几种其他方法来实现对齐,并且“A”、“B”和“C”位于各自的子图中,但没有成功。

有人可以帮忙吗?

@ Marapet - 谢谢,它现在几乎是完美的 - 当我添加“constraint=false”参数时,它看起来像这样:

Graph with constraint parameter

如果子图“A”位于“B”上方,而“B”又位于“C”上方,那就完美了。

最佳答案

在图表的第一个版本中,您可以通过添加属性 constraint=false 来禁用对 A-B 和 B-C 之间的边的节点排名的影响:

A -> B [lhead=clusterB, constraint=false];
B -> C [lhead=clusterC, constraint=false];

然后子图应该对齐。

关于alignment - 如何对齐点文件中的子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33025639/

相关文章:

css - 在中心对齐可变宽度的 div

css - 菜单和链接在左侧重叠

python-2.7 - "class_names"in export_graphviz 意外关键字错误

graphviz圆子图

c++ - boost 图相等性和子图

html - 从旁边的图片下方移动 table

linux - 如何使用点在 GraphViz 的标签中使用\"?

Graphviz 水平对齐顶部/底部的节点

algorithm - 包含给定节点集的最小连通子图

ios - 在 Swift 中以编程方式在 UILabel 内自由定位文本