2016-10-26 28 views
0

我作了如下圖:的Graphviz:水平對齊方式不工作向後箭頭

enter image description here

我想添加一個額外的箭頭,從「遠程回購」一路「工作副本指回「(標有‘混帳拉’),我想有一個箭頭最好先會小幅回落,然後離開,再向上。

當我只是一個箭頭添加到代碼,圖形最終看起來像這樣:

enter image description here

這是代碼:

digraph G { 
    /* set direction of graph to be left-->right */ 
    rankdir="LR"; 

    /* make boxes instead of ellipses */ 
    node [shape=box]; 

    /* should enforce nodes to be horizontally aligned */ 
    /* is not working, though... */ 
    rank=same; 

    /* assign labels to nodes */ 
    wc [label="working copy"]; 
    id [label="index"]; 
    lr [label="local repo"]; 
    rr [label="remote repo"]; 

    wc -> id [label="git add"]; 
    id -> lr [label="git commit"]; 
    lr -> rr [label="git push"]; 

    rr -> wc [label="git pull"]; 
} 

問題:爲什麼水平對齊被破壞以及如何解決這個問題?

後續問題:如何使箭頭朝下,然後離開,然後向上? (或者說是做到這一點使用某種程度上無形/假節點的唯一途徑?)

回答

1

您可以修改有問題的邊緣與constraint=false屬性。然後你會收到下面的圖表。

enter image description here

如果你喜歡邊更角度你也可以splines=ortho的圖形。

enter image description here

請工作示例檢查http://graphviz.it/#/mqNwRgzu。下面我粘貼了源代碼。

digraph G { 
    /* set direction of graph to be left-->right */ 
    rankdir="LR"; 
    splines=ortho; 

    /* make boxes instead of ellipses */ 
    node [shape=box]; 

    /* should enforce nodes to be horizontally aligned */ 
    /* is not working, though... */ 
    rank=same; 

    /* assign labels to nodes */ 
    wc [label="working copy"]; 
    id [label="index"]; 
    lr [label="local repo"]; 
    rr [label="remote repo"]; 

    wc -> id [label="git add"]; 
    id -> lr [label="git commit"]; 
    lr -> rr [label="git push"]; 

    rr -> wc [label="git pull", constraint=false]; 
}