2013-04-11 104 views
0

有人可以幫我弄清楚爲什麼下面的圖表永遠不會生成點?我認爲這個問題與頭部和尾部有關。如果我把它們拿出來,它就會起作用,但理想情況下,我希望那些因文體原因而停留。graphviz問題永遠不會完成

digraph G { 
    nodesep = 0.5; 
    0 [width=0.75, height=0.75, fontsize=20]; 
    1 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    2 [width=0.75, height=0.75, fontsize=20]; 
    3 [width=0.75, height=0.75, fontsize=20]; 
    4 [width=0.75, height=0.75, fontsize=20]; 
    5 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    6 [width=0.75, height=0.75, fontsize=20]; 
    7 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    8 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    9 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    10 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    11 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    12 [width=0.75, height=0.75, fontsize=20]; 
    subgraph directed{ 
      rankdir= LR;rank= max; 
      0->1->2->3->4->5->6->7->8->9->10->11->12; 
    } 
    subgraph undirected{ 
      rankdir= LR;rank= min;edge[tailport=n,headport=n]; 
      0->1[dir=none, color=red]; 
      0->2[dir=none, color=red]; 
      1->9[dir=none, color=red]; 
      2->3[dir=none, color=red]; 
      2->8[dir=none, color=red]; 
      3->4[dir=none, color=red]; 
      4->8[dir=none, color=red]; 
      7->9[dir=none, color=red]; 
      8->9[dir=none, color=red]; 
      9->10[dir=none, color=red]; 
      9->11[dir=none, color=red]; 
      10->11[dir=none, color=red]; 
    } 
} 

回答

0

很難知道你在做什麼。然而,有圖有一些問題:

  • 節點不能多子圖的一部分 - 他們要麼在圖表或子圖,無論他們在哪裏出現第一。你的哪裏應該出現?
  • rankdir屬性,不能被應用到

編輯

您的評論跟進,這裏是沒有任何子圖版本。但是,你不會喜歡邊緣的路由,這些東西很難控制。

想法是將節點排成一條直線,然後將其他邊與constraint=false相加以便不影響節點的排名。

digraph G { 
    nodesep = 0.5; 
    node[width=0.75, height=0.75, fontsize=20]; 
    rankdir=LR; 

    0; 
    1 [shape=square]; 
    2; 
    3; 
    4; 
    5 [shape=square]; 
    6; 
    7 [shape=square]; 
    8 [shape=square]; 
    9 [shape=square]; 
    10 [shape=square]; 
    11 [shape=square]; 
    12; 

    0->1->2->3->4->5->6->7->8->9->10->11->12; 

    edge[constraint=false, tailport=n,headport=n,dir=none, color=red]; 
    0->1; 
    0->2; 
    1->9; 
    2->3; 
    2->8; 
    3->4; 
    4->8; 
    7->9; 
    8->9; 
    9->10; 
    9->11; 
    10->11; 
} 
+0

本質上,我有需要通過有向圖和無向圖連接的節點。我希望節點(編號0-12)出現在一條直線上,其有向邊如下: 0→1→2→3→4→5→6→7 - > 8-> 9-> 10-> 11-> 12; 我想要無向邊連接到節點之間的北頭端口和尾端口。 – Karrde 2013-04-11 22:22:07

+0

@Karrde我對我的答案進行了更新。您應該將評論中的信息添加到您的問題中,這對了解您的問題很有用。 – marapet 2013-04-12 06:20:04

0

無需花費大量的時間通過挖源,它會是很難說爲什麼,你可以移動的麻煩要素出來的第二子圖來解決這個問題:

刪除1 - > 9和2-> 8,並將它們添加到它下面:

digraph G { 
    nodesep = 0.5; 
    0 [width=0.75, height=0.75, fontsize=20]; 
    1 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    2 [width=0.75, height=0.75, fontsize=20]; 
    3 [width=0.75, height=0.75, fontsize=20]; 
    4 [width=0.75, height=0.75, fontsize=20]; 
    5 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    6 [width=0.75, height=0.75, fontsize=20]; 
    7 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    8 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    9 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    10 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    11 [width=0.75, height=0.75, fontsize=20, shape=square]; 
    12 [width=0.75, height=0.75, fontsize=20]; 
    subgraph directed{ 
      rankdir= LR;rank= max; 
      0->1->2->3->4->5->6->7->8->9->10->11->12; 
    } 
    subgraph undirected{ 
      rankdir= LR;rank= min;edge[tailport=n,headport=n]; 
      0->1[dir=none, color=red]; 
      0->2[dir=none, color=red]; 
      2->3[dir=none, color=red]; 
      3->4[dir=none, color=red]; 
      4->8[dir=none, color=red]; 
      7->9[dir=none, color=red]; 
      8->9[dir=none, color=red]; 
      9->10[dir=none, color=red]; 
      9->11[dir=none, color=red]; 
      10->11[dir=none, color=red]; 
    } 
    1->9[dir="none", color="red", headport="n"]; 
    2->8[dir="none", color="red", headport="n"]; 
} 
相關問題