2014-03-13 177 views
0

我在Mediawiki網站內部使用GraphViz,這意味着我無法在svg文件上工作(不幸)。 我創造了這個圖形GraphViz創建常規邊緣

digraph GPPubProcess{ 
rankdir="TB"; 
node [shape = box fontsize=10]; 
edge [fontsize=10]; 
graph[size="7.75,10.25" overlap = false]; 

subgraph c2 { 
    rank="same"; 
    N02 [label="Two?" shape=hexagon margin=0]; 
    N03 [label="Three"]; 
} 

subgraph c4 { 
    rank="same"; 
    N07 [label="Seven"]; 
    N06 [label="Six?" shape=hexagon margin=0]; 
    N05 [label="Five"]; 
} 

subgraph c8 { 
    rank="same"; 
    N11 [label="Eleven)" shape=hexagon margin=0]; 
    N12 [label="Twelve"]; 
} 

subgraph c9 { 
    rank="same"; 
    N13 [label="Thirteen?" shape=hexagon margin=0]]; 
    N14 [label="Fourteen"]; 
N17 [label="COMPLETED"]; 
} 

N00 [shape=point]; 
N01 [label="One"]; 
N02 [label="Two?" shape=hexagon margin=0]; 
N04 [label="Four?" shape=hexagon margin=0]; 
N08 [label="Eight"]; 
N09 [label="Nine"]; 
N10 [label="Ten?" shape=hexagon margin=0]; 
N99 [shape=point]; 
N00->N01:n; 
N01:s->N02:n; 
N02:s->N04:n [label=" yes"]; 
N04:s->N05:n [label=" no" weight=30]; 
N05:s->N08:n [weight=30]; 
N08:s->N09:n [weight=30]; 
N09:s->N10:n [weight=30]; 
N10:s->N11:n [label=" no" weight=30]; 
N11:s->N17:n [label=" no"]; 
N17:s->N99; 

N02 -> N03 [weight=0]; 
N04:e -> N06:n [label=" yes"]; 
N06 -> N05 [label=" no"] [weight=0]; 
N06 -> N07 [label=" yes"]; 
N10:e -> N06:s [label=" yes" weight=5]; 
N03:s -> N07:n; 
N07:e -> N09:e [weight=0]; 

N11:e -> N12:w; 

N15 [label="Fifteen"]; 
N16 [label="Sixteen"]; 

N12:s->N13:n [weight=5]; 
N13:s->N15:n [label=" no"]; 
N15:s->N16:n; 

N13:e->N14:w [label=" yes" weight=5]; 

N14:n->N07:s; 

N16:w->N05:w [weight=0]; 

} 

產生幾乎什麼我都喜歡,但鏈接sixteen->五,ten->六thirteen-> 14讓很多節點之間激流回旋的。有沒有辦法讓他們正規化?

此外,六到五之間的聯繫朝着錯誤的方向發展,但我無法做到正確嗎?有什麼竅門嗎?

非常感謝。

喬治

回答

0

我會通過移除weight和指南針點開始的指令(N,:即:S,:W)。這些迫使dot做出一些奇怪的決定,特別是指南針點。如果您需要對默認版本進行更改,請一次進行一項小改動。不幸的是,你試圖強制點做一個特定的圖表,它往往得到的怪異。

由於您無法使用SVG,因此在某些時候您必須放棄準確獲取所需的圖形並接受點創建的圖形。有多少你可以強制點的限制。

六到五之間的聯繫(N06 -> N05)應該有箭頭從六到五。如果您看到指向六的箭頭,我認爲這是早期版本Graphviz中的一個錯誤。嘗試更新到最新版本。

此代碼:

digraph GPPubProcess{ 
    rankdir="TB"; 
    node [shape = box fontsize=10]; 
    edge [fontsize=10]; 
    graph[size="7.75,10.25" overlap = false]; 

    subgraph c2 { 
     rank="same"; 
     N02 [label="Two?" shape=hexagon margin=0]; 
     N03 [label="Three"]; 
    } 

    subgraph c4 { 
     rank="same"; 
     N07 [label="Seven"]; 
     N06 [label="Six?" shape=hexagon margin=0]; 
     N05 [label="Five"]; 
    } 

    subgraph c8 { 
     rank="same"; 
     N11 [label="Eleven)" shape=hexagon margin=0]; 
     N12 [label="Twelve"]; 
    } 

    subgraph c9 { 
     rank="same"; 
     N13 [label="Thirteen?" shape=hexagon margin=0]; 
     N14 [label="Fourteen"]; 
     N17 [label="COMPLETED"]; 
    } 

    N00 [shape=point]; 
    N01 [label="One"]; 
    N02 [label="Two?" shape=hexagon margin=0]; 
    N04 [label="Four?" shape=hexagon margin=0]; 
    N08 [label="Eight"]; 
    N09 [label="Nine"]; 
    N10 [label="Ten?" shape=hexagon margin=0]; 
    N99 [shape=point]; 
    N00->N01; 
    N01->N02; 
    N02->N04 [label=" yes"]; 
    N04->N05 [label=" no"]; 
    N05->N08; 
    N08->N09; 
    N09->N10; 
    N10->N11 [label=" no"]; 
    N11->N17 [label=" no"]; 
    N17->N99; 

    N02 -> N03; 
    N04 -> N06 [label=" yes"]; 
    N06 -> N05 [label=" no"]; 
    N06 -> N07 [label=" yes"]; 
    N10 -> N06 [label=" yes"]; 
    N03 -> N07; 
    N07 -> N09; 

    N11 -> N12; 

    N15 [label="Fifteen"]; 
    N16 [label="Sixteen"]; 

    N12->N13; 
    N13->N15 [label=" no"]; 
    N15->N16; 

    N13->N14 [label=" yes"]; 
    N14->N07; 

    N16->N05; 

} 

創建此圖:

no constraints

加入[constraint=false]N06 -> N05有助於消除各地N06交叉,但隨後推N11和N17的方式到左側:

with constraint

+0

謝謝,史蒂夫,這幫了很多!有沒有辦法讓頁面的一側更加重要,比如向左走?所以箱子在那邊對齊。 – GIMBorgo

+0

我沒有辦法知道,但我仍然是一位GraphViz初學者。 – SSteve

+0

@GIMBorgo這看起來像一個UML活動圖。在GraphViz之上運行的PlantUML支持以下圖表:http://plantuml.com/activity2.html#simple您甚至可以在MediaWiki:https://www.mediawiki中使用它。組織/維基/擴展:PlantUML – Fuhrmanator