Question

I'm using dot to compile. So I have two nodes in cluster0 (MATH1036 and MATH1034). When I try to make an edge from MATH1034 to a node outside the cluster (n1), it freaks out and removes MATH1034 from cluster0.

digraph G {
    labelloc="t";
    label="";
    graph [splines=spline, nodesep=1]
  compound=true;

    subgraph cluster0{
        label="Math 1";
        MATH1034[label="MATH1034\nAlgebra"];
        MATH1036[label="MATH1036\nCalculus"];
        {rank=same;MATH1036->MATH1034;}
    }
    COMS1015[label="COMS1015\nBCO"];
    COMS1017[label="COMS1017\nALG"];
    COMS1016[label="COMS1016\nDCS"];
    COMS1018[label="COMS1018\nADS"];

    subgraph cluster1{
        label="Math 2";
        MATH2007[label="MATH2007\nMC"];
        MATH2018[label="MATH2018\nGT"];
        MATH2019[label="MATH2019\nLA"];
        STAT2XXX[label="STAT2XXX\nIntro to MS\nor\nSTAT1003\nStats 1"];
    }
    COMS2003[label="COMS2003\nAAA"];
    COMS2XXX[label="COMS2XXX\nMC"];
    COMS2002[label="COMS2002\nDBF"];
    COMS2001[label="COMS2001\nOS"];

    COMS3000[label="COMS3000\nAAI"];
    COMS3003[label="COMS3003\nFLA"];
    COMS3004[label="COMS3004\nAN"];
    COMS3002[label="COMS3002\nSE"];

    // This line will hide the formatting nodes.
    //node[shape=none,width=0,height=0, label=""];

    // THIS NEXT LINE CAUSES THE PROBLEM
    // If I remove MATH1034 from this line, things go normal.
    {rank=same;MATH1034->n1[ltail=cluster0,dir=none ]; n1->n2->n3->n4->n5[dir=none];}

    n1->COMS1015[style=dotted];
    n2->COMS1016[style=dotted];
    n4->COMS1017[style=dotted];
    n5->COMS1018[style=dotted];

    MATH1034 -> MATH2007[lhead=cluster1, ltail=cluster0];
    MATH2018 -> STAT2XXX[style=invis];
    MATH2007 -> MATH2019[style=invis];

    //edge[dir=none];
    n3->n6->n7[arrowhead=none];
    {rank=same; COMS1016->n6->COMS1017[style=invis];}
    {rank=same; COMS2001->n7[style=invis]; n7->COMS2003;}

    COMS1015 -> COMS2001;
    //{rank=same; COMS1017 -> p1 -> COMS1018;}
    //p1 -> COMS2003;
    //p1 -> COMS2XXX;
    COMS1017 -> COMS2XXX;
    COMS1017 -> COMS2001;
    COMS1017 -> COMS2003;

    COMS1018 -> COMS2003;
    COMS1018 -> COMS2XXX;
    COMS1018 -> COMS2002;

    COMS1016 -> COMS2003;
    COMS1016 -> COMS2001[weight=100,style=invis];

    MATH2007 -> COMS2001[ltail=cluster1,style=dotted]
    MATH2007 -> COMS2003[ltail=cluster1,style=dotted]


    {rank=same;COMS2XXX -> COMS2002[dir=back, style=dotted]}
    {rank=same;COMS2003 -> COMS2XXX[dir=back]}

subgraph cluster5{ 
    label="";
    {rank=same;COMS3004 -> COMS3003 -> COMS3000 ->  COMS3002[style=invis];}
}
    COMS2003 -> COMS3000[weight=1000];
    COMS1016 -> COMS3003;

    COMS2001 -> COMS3004[weight=1000];
    COMS2002 -> COMS3002[weight=1000];

    MATH2007 -> COMS3004[ltail=cluster1,lhead=cluster5];

}

The MATH modules should be next to each other and in a box.

Here is the very broken one:

broken layout

Here is the correct layout, but without the edge between MATH1034 and n1:

correct layout

Any help would really be appreciated I've looked everywhere and nothing seems to work.

Was it helpful?

Solution

The node Math1034 is in two different subgraphs which isn't allowed. dot actually emits the following warning:

Warning: MATH1034 was already in a rankset, deleted from cluster G

Warning: MATH1034 -> MATH2007: tail not inside tail cluster cluster0

Warning: MATH1034 -> n1: tail not inside tail cluster cluster0


The solution is to remove MATH1034 from the second cluster, and add the edge without constraining ranks:

{rank=same; n1[ltail=cluster0,dir=none ]; n1->n2->n3->n4->n5[dir=none];}
MATH1034 -> n1[constraint=false];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top