2011-12-07 117 views
0

我想在頂部繪製兩條平行的水平線。怎麼做? 我的代碼在這裏。輸出線的高度相同,所以不起作用。如何創建兩條平行線?

digraph G { 

    graph [center, rankdir=TB, bgcolor=black]; 
    edge [arrowsize=1, color=red, dir=none]; 

    node [penwidth=1, color=white, fontcolor=white, labelloc=b]; 

    BB1P1[shape=point, color=red, width=0.01]; 
    BB1P[shape=point, color=white, width=0.1]; 
    BB1PV[shape=point, color=red, width=0.01]; 
    BB1P2[shape=point, color=red, width=0.01]; 

    BB1P1 -> BB1P -> BB1PV -> BB1P2; 

    BB2P1[shape=point, color=red, width=0.01]; 
    BB2PV[shape=point, color=red, width=0.01]; 
    BB2P[shape=point, color=white, width=0.1]; 
    BB2P2[shape=point, color=red, width=0.01]; 

    BB2P1 -> BB2PV -> BB2P -> BB2P2; 

    { rank=same; BB1P1; BB1P; BB1PV; BB1P2 }; 
    { rank=same; BB2P1; BB2PV; BB2P; BB2P2 }; 

} 
+0

我添加兩個看不見的邊緣,它的工作。 BB1P1 - > BB2P1 [style = invis]; BB1P2 - > BB2P2 [style = invis]; – allenchen

回答

2

其實一個看不見的結點就足夠了:

digraph G { 
    graph [center, rankdir=TB, bgcolor=black]; 
    edge [arrowsize=1, color=red, dir=none]; 

    node [penwidth=1, color=red, fontcolor=white, labelloc=b, shape=point, width=0.01]; 

    { 
     rank=same; 
     BB1P1; 
     BB1P[color=white, width=0.1]; 
     BB1PV; 
     BB1P2; 
    } 

    { 
     rank=same; 
     BB2P1; 
     BB2PV; 
     BB2P[color=white, width=0.1]; 
     BB2P2; 
    } 

    BB1P1 -> BB1P -> BB1PV -> BB1P2; 
    BB2P1 -> BB2PV -> BB2P -> BB2P2; 
    BB1P1 -> BB2P1[style=invis]; 
} 

甚至更​​簡單,只是改變rankdirLR

digraph G { 
    graph [center, rankdir=LR, bgcolor=black]; 
    edge [arrowsize=1, color=red, dir=none]; 

    node [penwidth=1, color=red, fontcolor=white, labelloc=b, shape=point, width=0.01]; 

    BB1P[color=white, width=0.1]; 
    BB2P[color=white, width=0.1]; 

    BB1P1 -> BB1P -> BB1PV -> BB1P2; 
    BB2P1 -> BB2PV -> BB2P -> BB2P2; 
} 
+0

太棒了!非常感謝你。 – allenchen