alignment - Graphviz水平对齐子图

标签 alignment graphviz rank subgraph

我有以下代码:

    digraph G {
        bgcolor=antiquewhite;
        compound=true;
        { 
            rankdir=LR ; 
            rank=same g0 p1 p2 p3 h1; 
        }
        subgraph cluster0 {
            style=filled;
            color=khaki;
            g0 [label="G",shape=circle,style="filled", color="red", fillcolor="lightpink"]
            label = "Cluster 0";
            g0 -> p1;
        }
        subgraph cluster1 {
            style=filled;
            color=khaki;
            p1 [label="S2",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            p2 [label="S3",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            p3 [label="S3",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            label = "Cluster 1";
            p1 -> p2 -> p3 [arrowhead=none] ;
        }
        subgraph cluster2 {
            style=filled;
            color=khaki;
            h1 [label="h1",shape=box,style="invis"];
            label = "Cluster 2";
            p3 -> h1; 
        }
    }

除了子图不显示外,一切都完美无缺。一旦在集群外定义了等级,子图就会消失。

enter image description here

如果在簇体内部定义,则簇之间的相同等级将丢失。

最佳答案

  • rankdir仅适用于图形级别
  • 一个节点可能只属于一个集群

  • .
    digraph G {
        rankdir=LR ; 
        bgcolor=antiquewhite;
        compound=true;
        subgraph cluster0 {
            style=filled;
            color=khaki;
            g0 [label="G",shape=circle,style="filled", color="red", fillcolor="lightpink"]
            label = "Cluster 0";
        }
        subgraph cluster1 {
            style=filled;
            color=khaki;
            p1 [label="S2",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            p2 [label="S3",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            p3 [label="S3",shape=box,style="filled", color="blue", fillcolor="skyblue"];
            label = "Cluster 1";
            p1 -> p2 -> p3 [arrowhead=none] ;
        }
        subgraph cluster2 {
            style=filled;
            color=khaki;
            h1 [label="h1",shape=box,style="invis"];
            label = "Cluster 2";
        }
        g0 -> p1;
        p3 -> h1; 
    }
    



    enter image description here

    关于alignment - Graphviz水平对齐子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30170133/

    相关文章:

    html - 向右添加图像会将下表向右推

    css - 对齐对象

    python - 安装 Graphviz 2.38 后的 "RuntimeError: Make sure the Graphviz executables are on your system' s 路径

    tree - 制作graphviz树让 parent 以 child 为中心

    python - 删除/修改 graphviz 中的边

    python - numpy 矩阵排名不正确的结果

    postgresql - 如何在 PostgreSQL 中获取每个等级的平均行数?

    html - 我怎样才能在html上对齐这种段落

    python - 为什么 rank 方法的升序参数不起作用?

    c++ - VC 中哪种大小的结构成员对齐会带来性能优势?