2012-10-25 108 views
4

我用dot -Tsvg做了一個圖表。dot/graphviz:如何強制2個節點並排

這點語言文件我提出:

digraph genealogy { 
    size = "7,7"; 
    node [fontsize = "10", shape = "box", style="filled", fillcolor="aquamarine"]; 
    p1 [ fillcolor="aquamarine", label="node" ]; 
    p2 [ fillcolor="aquamarine", label="node" ]; 
    p3 [ fillcolor="aquamarine", label="node" ]; 
    p4 [ fillcolor="aquamarine", label="node" ]; 
    p5 [ fillcolor="aquamarine", label="node" ]; 
    p6 [ fillcolor="aquamarine", label="node" ]; 
    p7 [ fillcolor="aquamarine", label="node" ]; 
    p8 [ fillcolor="aquamarine", label="node" ]; 
    p9 [ fillcolor="aquamarine", label="node" ]; 
    p11 [ fillcolor="aquamarine", label="node" ]; 
    p12 [ fillcolor="aquamarine", label="node" ]; 
    p13 [ fillcolor="aquamarine", label="node" ]; 
    p16 [ fillcolor="aquamarine", label="node" ]; 
    p17 [ fillcolor="aquamarine", label="node" ]; 
    b1 [ shape = "point", style="filled", fillcolor="white" ]; 
    p3 -> b1 [arrowhead = "none", color="red"]; 
    b2 [ shape = "point", style="filled", fillcolor="white" ]; 
    p2 -> b2 [arrowhead = "none", color="red"]; 
    p3 -> b2 [arrowhead = "none", color="red"]; 
    b3 [ shape = "point", style="filled", fillcolor="white" ]; 
    p4 -> b3 [arrowhead = "none", color="red"]; 
    p5 -> b3 [arrowhead = "none", color="red"]; 
    b4 [ shape = "point", style="filled", fillcolor="white" ]; 
    p6 -> b4 [arrowhead = "none", color="red"]; 
    p11 -> b4 [arrowhead = "none", color="red"]; 
    b2 -> p1 [arrowhead = "onormal", color="red"]; 
    b3 -> p2 [arrowhead = "onormal", color="red"]; 
    b3 -> p6 [arrowhead = "onormal", color="red"]; 
    b3 -> p7 [arrowhead = "onormal", color="red"]; 
    b4 -> p8 [arrowhead = "onormal", color="red"]; 
    b4 -> p9 [arrowhead = "onormal", color="red"]; 
    b1 -> p12 [arrowhead = "onormal", color="red"]; 
    b1 -> p13 [arrowhead = "onormal", color="red"]; 
    b1 -> p16 [arrowhead = "onormal", color="red"]; 
    p4 -> p5 [dir="none", arrowhead = "none", color="blue"]; 
    p7 -> p17 [dir="none", arrowhead = "none", color="blue"]; 
} 

這是結果:

我想迫使以藍線連接的節點通過將側側(水平),而不是在彼此之下或在另一個瘋狂的位置。

這可能嗎?

感謝您的輸入/意見! :)

回答

4

您可以利用排名屬性。設置排名=「相同」或排名=「來源」可能會有幫助。這將兩個節點放在同一級別或最低級別上。這是可能性之一:

digraph genealogy { 
    size = "7,7"; 
    node [fontsize = "10", shape = "box", style="filled", fillcolor="aquamarine"]; 

    subgraph _1 { 
    rank="same"; 
    p4 [ fillcolor="aquamarine", label="node" ]; 
    p5 [ fillcolor="aquamarine", label="node" ]; 
    p4 -> p5 [dir="none", arrowhead = "none", color="blue"]; 
} 
    subgraph _2 { 
    rank="source"; 
    p7 [ fillcolor="aquamarine", label="node" ]; 
    p17 [ fillcolor="aquamarine", label="node" ]; 
    p7 -> p17 [dir="none", arrowhead = "none", color="blue"]; 
} 

p1 [ fillcolor="aquamarine", label="node" ]; 
p2 [ fillcolor="aquamarine", label="node" ]; 
p3 [ fillcolor="aquamarine", label="node" ]; 
p6 [ fillcolor="aquamarine", label="node" ]; 
p8 [ fillcolor="aquamarine", label="node" ]; 
p9 [ fillcolor="aquamarine", label="node" ]; 
p11 [ fillcolor="aquamarine", label="node" ]; 
p12 [ fillcolor="aquamarine", label="node" ]; 
p13 [ fillcolor="aquamarine", label="node" ]; 
p16 [ fillcolor="aquamarine", label="node" ]; 
b1 [ shape = "point", style="filled", fillcolor="white" ]; 
p3 -> b1 [arrowhead = "none", color="red"]; 
b2 [ shape = "point", style="filled", fillcolor="white" ]; 
p2 -> b2 [arrowhead = "none", color="red"]; 
p3 -> b2 [arrowhead = "none", color="red"]; 
b3 [ shape = "point", style="filled", fillcolor="white" ]; 
p4 -> b3 [arrowhead = "none", color="red"]; 
p5 -> b3 [arrowhead = "none", color="red"]; 
b4 [ shape = "point", style="filled", fillcolor="white" ]; 
p6 -> b4 [arrowhead = "none", color="red"]; 
p11 -> b4 [arrowhead = "none", color="red"]; 
b2 -> p1 [arrowhead = "onormal", color="red"]; 
b3 -> p2 [arrowhead = "onormal", color="red"]; 
b3 -> p6 [arrowhead = "onormal", color="red"]; 
b3 -> p7 [arrowhead = "onormal", color="red"]; 
b4 -> p8 [arrowhead = "onormal", color="red"]; 
b4 -> p9 [arrowhead = "onormal", color="red"]; 
b1 -> p12 [arrowhead = "onormal", color="red"]; 
b1 -> p13 [arrowhead = "onormal", color="red"]; 
b1 -> p16 [arrowhead = "onormal", color="red"]; 

} 

Output is here

+0

非常感謝您! :)具有'rank =「相同」'屬性的子圖解決了我的問題。 – ryu

+0

很高興能成爲幫助! –