2013-04-11 95 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"]; 
} 
相关问题