2011-06-24 58 views
3

我的結構在子圖中有兩個主鏈和副節點。每件事看起來不錯,但是當我關閉兩條鏈時,子圖中的所有框都跳到右側。 在我的代碼結束時,您可以刪除「我」 - >「J」,那麼您可以看到我的意思是最好的。 我不是英語母語的人,對我的英語感到抱歉,我是一名graphviz新手。Graphviz - 盒子定位問題

digraph G { 
    size ="6,6"; 
    node [color=black fontsize=12, shape=box, fontname=Helvetica]; 

subgraph { 
    rank = same; 
    "b"->"B"[arrowhead=none]; 
    } 

subgraph { 
    rank=same; 
    "c"->"C"[arrowhead=none]; 
    } 

subgraph { 
     rank=same; 
     "e"->"E" [arrowhead=none]; 
    } 

subgraph { 
    rank = same; 
    "f"->"F"[arrowhead=none]; 
} 

subgraph { 
    rank = same; 
    "g"->"G"[arrowhead=none]; 
} 

"0" -> "A" -> "B" -> "C"->"D" -> "E" -> "F" -> "G" -> "H"->"I"; 
"0" -> "K"->"L"->"M"->"N"->"O" ->"P"->"1"; 

subgraph { 
    rank = same; 
    "L"->"l"[arrowhead=none]; 
} 

subgraph { 
    rank=same; 
    "M"->"m"[arrowhead=none]; 
} 

subgraph { 
    rank=same; 
    "N"->"n" [arrowhead=none]; 
} 

subgraph { 
    rank = same; 
    "O"->"o"[arrowhead=none]; 
} 

subgraph { 
    rank = same; 
    "P"->"p"[arrowhead=none]; 
} 

"1"->"J"; 
"I"->"J"; 
} 

enter image description here


"I"->"J";刪除:

enter image description here

回答

5

這是我怎麼會去一下:每個主鏈與創建羣集其邊節點:

digraph G { 
    size ="6,6"; 
    node [color=black fontsize=12, shape=box, fontname=Helvetica]; 

    subgraph[style=invis]; 

    subgraph cluster0 { 
     A -> B -> C -> D -> E -> F -> G -> H -> I; 
     edge[arrowhead=none]; 
     {rank = same; b->B;} 
     {rank = same; c->C;} 
     {rank = same; e->E;} 
     {rank = same; f->F;} 
     {rank = same; g->G;} 
    } 

    subgraph cluster1 { 
     K -> L -> M -> N -> O -> P -> 1 -> J; 
     edge[arrowhead=none]; 
     {rank = same; L->l;} 
     {rank = same; M->m;} 
     {rank = same; N->n;} 
     {rank = same; O->o;} 
     {rank = same; P->p;} 
    } 
    0 -> A; 
    0 -> K; 
    I -> J; 
} 

,導致:

graphviz output

+0

謝謝你這麼mutch。這正是我期待的。 – user813809

+0

我很高興它有幫助!如果這回答您的問題,您應該將其標記爲接受的答案。 – marapet