2013-01-10 77 views
1

之間對準我用GraphViz的有以下點文件:力GraphViz的力子

digraph "Fast-forward" 
{ 
    rankdir=LR; 
    subgraph master 
    { 
     "5c071a6b2c" -> "968bda3251"; 
    } 
    subgraph branch 
    { 
     "35ee8ce6b6" [color="blue"] [style="filled"]; 
     "968bda3251" -> "9754d40473" [weight=0]; 
     "9754d40473" -> "9e59700d33" -> "35ee8ce6b6"; 
    } 
    subgraph c1 
    { 
     rankdir=LR; 
     rank="same"; 
     "remote/master/HEAD" [shape=box]; 
     "remote/master/HEAD" -> "35ee8ce6b6" [weight=0]; 
     oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"]; 
     newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"]; 
     oldmh -> "968bda3251" [weight=0]; 
     newmh -> "35ee8ce6b6" [weight=0]; 
    } 
} 

它給我這樣的事情: Bag thing

但我想這樣的事情:

             white 
                 | 
                 \/ 
        "9754d40473" -> "9e59700d33" -> "35ee8ce6b6"; 
        /        /\ 

5c071a6b2c - > 968bda3251

   /\           | 
       | 
      red          blue 

我該怎麼做?

對您的幫助, 提前致謝。

回答

3

我傾向於與定義所有的節點首先需要特殊需求(例如處於同一等級或具有特殊形狀/顏色),然後定義鏈接。這樣,您確信rank=same節點已正確分組,並按正確的順序進行定義。

如果沒有weight=0,所有的邊鏈都會在最上面。將weight=0添加到您想要的底部。

digraph "Fast-forward" 
{ 
    rankdir=LR; 
    subgraph c1 { 
     rank="same"; 
     "968bda3251"; 
     oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"]; 
    } 
    subgraph c2 
    { 
     rank="same"; 
     "remote/master/HEAD" [shape=box]; 
     "35ee8ce6b6" [color="blue"] [style="filled"]; 
     newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"]; 
    } 
    "5c071a6b2c" -> "968bda3251" -> "9754d40473" -> "9e59700d33" -> "35ee8ce6b6"; 
    oldmh -> "968bda3251" [weight=0]; 
    "remote/master/HEAD" -> "35ee8ce6b6"; 
    newmh -> "35ee8ce6b6" [weight=0]; 
} 

The results from dot

如果你真的想96和97之間的點動,你可以這樣來做:

digraph "Fast-forward" 
{ 
    rankdir=LR; 
    subgraph c1 { 
     rank=same; 
     "968bda3251"; 
     oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"]; 
    } 
    subgraph c1p5 { 
     rank=same; 
     "9754d40473"; 
     inviso [style="invis"]; 
    } 
    subgraph c2 
    { 
     rank="same"; 
     "remote/master/HEAD" [shape=box]; 
     "35ee8ce6b6" [color="blue"] [style="filled"]; 
     newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"]; 
    } 
    "5c071a6b2c" -> "968bda3251"; 
    "968bda3251" -> "9754d40473" [weight=0]; 
    "9754d40473" -> "9e59700d33" -> "35ee8ce6b6"; 
    oldmh -> "968bda3251" [weight=0]; 
    "remote/master/HEAD" -> "35ee8ce6b6"; 
    newmh -> "35ee8ce6b6" [weight=0]; 
    "968bda3251" -> inviso [style="invis"]; 
    "9754d40473" -> inviso [style="invis"]; 
} 

enter image description here

0

rank="same"影響的子圖的所有節點,所以你必須在兩個部分來分割你的標籤子:

digraph "Fast-forward" 
{ 
    rankdir=LR; 
    subgraph master 
    { 
     "5c071a6b2c" -> "968bda3251"; 
    } 
    subgraph branch 
    { 
     "968bda3251" -> "9754d40473" [weight=0]; 
     "9754d40473" -> "9e59700d33" -> "35ee8ce6b6"; 
     "35ee8ce6b6" [color="blue"] [style="filled"]; 
    } 
    subgraph c1 
    { 
     rank="same"; 
     "remote/master/HEAD" [shape=box]; 
     "remote/master/HEAD" -> "35ee8ce6b6" [weight=0]; 
     newmh [label="master/HEAD"] [shape=box] [color="blue"] [style="filled"]; 
     newmh -> "35ee8ce6b6" [weight=0]; 
    } 
    subgraph c2 
    { 
     rank="same"; 
     oldmh [label="master/HEAD"] [shape=box] [color="red"] [style="filled"]; 
     oldmh -> "968bda3251" [weight=0]; 
    } 
} 

這會給你: enter image description here

+0

謝謝您的回答,但我已經意識到我的'asciiart'打印不正確,是否可以將遠程/主/ HEAD放在頂部?感謝提前。 – GlinesMome

+0

嘗試移動子圖c1上方的子圖c2。節點的定義順序可能會影響它們在結果圖上顯示的順序。這不是保證,但它可能有效。 **沒關係,沒有工作。我會再看一看。** – EdwinW