How to enforce the left-to-right node ordering in GraphViz rank layout?

后端 未结 1 855
心在旅途
心在旅途 2020-12-30 01:04

I am visualizing a collection of process with GraphViz. Each process consists of some Read or Write operations in program order. Naturally, it is desirable to arrange the op

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 01:26

        digraph G 
    {
    ranksep = 1.0; size = "10,10";
    { 
        node [shape = plaintext, fontsize = 20];
        0 -> 1 -> 2 -> 3 -> 4;
    }
    node [shape = box];
    {
    rank = same;
    0->wy1->rf1->rc1->rz1->ry1->ra1->rb1->rx2 [color=white];
    rankdir=LR;
    }
    {
    rank = same;
    1->wf1[color=white];
    rankdir=LR
    }
    {
    rank = same;
    2->wx2->wc1[color=white];
    rankdir=LR;
    }
    {
    rank = same;
    3->wf2->wz2->wx3->wa1[color=white];
    rankdir=LR;
    }
    {
    rank = same;
    4->wz1->wy2->wx5->wb1[color=white];
    rankdir=LR;
    }
    wy1 -> rf1;
    rf1 -> rc1;
    rc1 -> rz1;
    rz1 -> ry1;
    ry1 -> ra1;
    ra1 -> rb1;
    rb1 -> rx2;
    wx2 -> wc1;
    wf2 -> wz2;
    wz2 -> wx3;
    wx3 -> wa1;
    wz1 -> wy2;
    wy2 -> wx5;
    wx5 -> wb1;
    wf1 -> rf1[color = blue];
    wc1 -> rc1[color = blue];
    wz1 -> rz1[color = blue];
    wy1 -> ry1[color = blue];
    wa1 -> ra1[color = blue];
    wb1 -> rb1[color = blue];
    wx2 -> rx2[color = blue];
    
    // W'WR Order:
    wx3 -> wx2[style = dashed, color = red];
    
    // W'WR Order:
    wx5 -> wx2[style = dashed, color = red];
    }
    

    I am not quite sure that i've correctly got your problem, but try using this and comment please if it is what you want. I've added invisible edges for correct ranking of nodes and used rankdir to use left-right layout.

    0 讨论(0)
提交回复
热议问题