Graphviz:水平对齐子图

6

我有以下代码:

    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

如果在一个集群内部定义,集群之间的相同等级将会丢失。

1个回答

5
  • 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; 
}

提供

在此输入图片描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接