2017-08-07 131 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

从猫的箭头现在连接到每个子图簇中的一个特定节点。相反,箭头应该连接到外部盒子本身。 (请考虑我发布的图片)。谢谢 –

相关问题