2017-08-07 128 views
0
digraph G{ 
    rankdir=LR; 
    size="12.34"; 
    node [shape="rectangle"] 
    apple -> "ball" 
    subgraph cluster_0 { 
      rankdir=LR; 
      node[style = filled]; 
      color = blue 
    subgraph cluster_4{ 
      rankdir=LR; 
      node[style=filled]; 
      fontsize=15; 
      l[fontcolor=red] e[fontcolor=red] i[fontcolor=red] 
      g[fontcolor=red] k[fontcolor=red] 
      color=orange 
      } 
    subgraph cluster_3 { 
      rankdir=LR; 
      node [style=filled]; 
      fontsize=15 
      "wq"[fontcolor=red,fontsize=12] ". . . . " "wqnn" 
      [fontcolor=red,fontsize=12]; 
      label = "zebra"; 
      color=orange 
      } 
    subgraph cluster_2 { 
      rankdir=LR; 
      node [style=filled]; 
      fontsize=15 
      struct3 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d1}|{ a | b | c }}"]; 
      struct4 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d2}|{ a | b | c }}"]; 
      struct5 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d3}|{ a | b }}"]; 
      struct6 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d4}|{ a }}"]; 
      ". . . . . ." 
      struct7 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{dn}|{a }}"]; 
      label = "tiger"; 
      color=orange 
      } 
    subgraph cluster_1{ 
      node[ style = filled]; 
      struct1 [shape=record, 
      rankdir=LR,fontsize=12,fontcolor=red, label="{{n}|{ x| y| 
      z }}"]; 
      ". . . . . ." 
      struct2 [shape=record, 
      rankdir=LR,fontsize=12,fontcolor=red, label="{{m}|{ x | y 
      | z }}"]; 
      label = "lion"; 
      fontsize=15 
      color = orange 
      } 
      edge[color="violet"] 
      "cat" -> "wq" 
      "cat" -> "struct3" 
      "cat" -> "struct1" 
      "cat" -> "l" 
     } 
     "ball" -> "cat"[label="abc"]; 
} 

我是一個初學者(點語言和graphviz)。我寫這樣的代碼。但我想要水平線上的d1 d2 d3 d4框。請幫我graphviz(點語言)我可以在水平線上獲得節點嗎?

image.dot

如何讓這些箱子具有水平。我能爲此做些什麼?如何讓這些節點水平?提前致謝。

回答

0

是這樣的嗎?我做了不可見的鏈接來強制執行從左到右的順序。結合您的rankdir設置,這使得它們從左到右。

digraph G{ 
    rankdir=LR; 
    size="12.34"; 
    node [shape="rectangle"] 
compound=true; 


    subgraph cluster_0 { 
      rankdir=LR; 
      node[style = filled]; 
      color = blue 


    subgraph cluster_4{ 
      rankdir=LR; 
      node[style=filled]; 
      fontsize=15; 
      l[fontcolor=red] e[fontcolor=red] i[fontcolor=red] 
      g[fontcolor=red] k[fontcolor=red] 
      color=orange 

    l -> e -> i -> g -> k [style=invis]; 

      } 



    subgraph cluster_3 { 
      rankdir=LR; 
      node [style=filled]; 
      fontsize=15 
      "wq"[fontcolor=red,fontsize=12] ". . . . " "wqnn" 
      [fontcolor=red,fontsize=12]; 
      label = "zebra"; 
      color=orange 


    dummy3 [label = "" style=invis] 
    dummy4 [label = "" style=invis] 
    wqnn -> dummy3 -> dummy4 [style=invis] 
    wq -> ". . . . " -> "wqnn" [style=invis]; 
      } 


    subgraph cluster_2 { 
      rankdir=LR; 
      node [style=filled]; 
      fontsize=15 
      struct3 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d1}|{ a | b | c }}"]; 
      struct4 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d2}|{ a | b | c }}"]; 
      struct5 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d3}|{ a | b }}"]; 
      struct6 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{d4}|{ a }}"]; 

    struct3 -> struct4 -> struct5 -> struct6 -> struct7 [style=invis]; 

      struct7 [shape=record,fontsize=12, fontcolor=red, label=" 
      {{dn}|{a }}"]; 
      label = "tiger"; 
      color=orange 
      } 

    subgraph cluster_1{ 
      node[ style = filled]; 
      struct1 [shape=record, 
      rankdir=LR,fontsize=12,fontcolor=red, label="{{n}|{ x| y| 
      z }}"]; 
      ". . . . . ." 
      struct2 [shape=record, 
      rankdir=LR,fontsize=12,fontcolor=red, label="{{m}|{ x | y 
      | z }}"]; 
      label = "lion"; 
      fontsize=15 
      color = orange 

    dummy1 [label = "" style=invis] 
    dummy2 [label = "" style=invis] 
    struct2 -> dummy1 -> dummy2 [style=invis] 
    struct1 -> ". . . . . ." -> struct2 [stle=invis]; 
      } 


      edge[color="violet"] 
      "cat" -> "wq" [lhead=cluster_3 ] 
      "cat" -> "struct3" [lhead=cluster_2 ] 
      "cat" -> "struct1" [lhead=cluster_1 ] 
      "cat" -> "l" [lhead=cluster_4 ] 

     } 

     "ball" -> "cat"[label="abc"]; 
     apple -> "ball" 

} 

enter image description here

+0

謝謝你幫助我。這樣我需要。也適用於斑馬,獅子(子圖羣集)和最後一個箱子(節點)。你能幫我前進嗎?非常感謝 –

+0

箭頭(邊緣)將在盒子外(邊緣只會碰到黃色盒子)不應該放在盒子的邊上。你能考慮以上原始圖像嗎?謝謝。 –

+0

從貓的箭頭現在連接到每個子圖簇中的一個特定節點。相反,箭頭應該連接到外部盒子本身。 (請考慮我發佈的圖片)。謝謝 –

相關問題