使用Graphviz和Dot对两个集群进行对齐问题

时间:2015-02-04 01:21:05

标签: graphviz dot rank

我试图让以下点文件输出两个子图。我希望cluster0中的bLoop节点与集群2中的ISR结构对齐。我现在使用不可见节点执行此操作,但是在cluster0中留下了大量灰色空间的意外后果。

有没有办法在没有隐形节点的情况下做我想做的事情? 我还无法发布图片,所以这里是link

digraph G {
    ranksep=.75;
    nodesep = 1.5;
     node [shape = none]
    node[fontsize=16,fixedsize=false,width=0.7,shape=rectangle];
    edge[fontsize=16];
    ratio=fill;
    splines=false;  

    compound=true;
        subgraph cluster0 {
            node [style=filled];
            style=filled;
            color=lightgrey;
            label = "Setup and Background Loop";

            a0[label = "Peripheral Configs"];
            a1[label = "Solar Library Block Configs"];
            a2[label = "Enable Interrupts"];
            bgLoop[label = "Start Background Loop"];
            e0[shape=rectangle, style=invis, fixedsize=true, width=.01];

            a0 -> a1 -> a2 -> bgLoop;
            bgLoop ->e0[style=invis]

        }

        subgraph cluster1 {
                node [style=filled, shape = "doublecircle"];
                start
                style="invis"
            }

        subgraph cluster2 {
            node [shape=record,color=white];
            style=filled;
            color=lightgrey;
            label = "ISRs";
            struct1 [shape = record, color=white, label="{<f1> Slow ISR | <f2> Fast ISR }"]; 
        }

    concentrate = true;


    struct1 -> bgLoop[lhead=cluster0, ltail=cluster4,  constraint=true];
    bgLoop -> struct1[lhead=cluster4, ltail=cluster0, constraint=true];
    struct1 -> e0[style=invis, constraint=true];
    start -> a0[lhead=cluster0];
}

1 个答案:

答案 0 :(得分:2)

您需要辅助节点才能获得struct1的正确排名。

digraph G {
    ranksep=.75;
    nodesep = 1.5;
    node[fontsize=16,fixedsize=false,width=0.7,shape=rectangle];
    edge[fontsize=16];
    compound=true
        subgraph cluster2 { rank="max"
            node [shape=record,color=white];
            style=filled;
            color=lightgrey;
            label = "ISRs";
            struct1 [shape = record, color=white, label="{<f1> Slow ISR | <f2> Fast ISR }"]; 
        }

        subgraph cluster0 {
            node [style=filled];
            style=filled;
            color=lightgrey;
            label = "Setup and Background Loop";

            a0[label = "Peripheral Configs"];
            a1[label = "Solar Library Block Configs"];
            a2[label = "Enable Interrupts"];
            bgLoop[label = "Start Background Loop"];

            a0 -> a1 -> a2 -> bgLoop;

        }

        subgraph cluster1 {
                node [style=filled, shape = "doublecircle"];
                start
                style="invis"
            }


    {node [style=invis]; 0; 1; 2; 3; }
    {edge [style=invis]; 0->1->2->3->struct1; }

    struct1 -> bgLoop[lhead=cluster0, ltail=cluster2, constraint=false];
    bgLoop -> struct1[lhead=cluster2, ltail=cluster0, constraint=false];
    start -> a0[lhead=cluster0];
}

enter image description here