2017-03-04 69 views
0

我有一個圖形,其中有3個子圖放置在一個另一個上,我希望它們堆疊在一個頂部彼此(我不想要內容的方向子圖改變)。強制GraphViz將子圖對齊到一個下面

這個簡單的例子:

digraph G { 
 
rankdir=TB; 
 
    subgraph cluster_lkg{ 
 
     subgraph cluster_sentence_1{ 
 
      "A1","A2","A3" 
 
      "A1" -> "A2" 
 
      "A1" -> "A3" 
 
     } 
 
     subgraph cluster_concepts_1{ 
 
      "B1","B2","B3" 
 
      "B1" -> "B2" 
 
      "B1" -> "B3" 
 
     } 
 
    } 
 
    subgraph cluster_fkgs{ 
 
      "C1","C2","C3" 
 
      "C1" -> "C2" 
 
      "C1" -> "C3" 
 
    } 
 

 
}

回答

0

您需要連接羣集​​(或者更準確地說,集羣中的節點),以使您的rankdir = TB有效。您可以通過使用不可見邊這樣做:

digraph G 
{ 
    rankdir=TB;  
    subgraph cluster_lkg 
    { 
     subgraph cluster_sentence_1 
     { 
      "A1","A2","A3" 
      "A1" -> "A2" 
      "A1" -> "A3" 
     } 
     subgraph cluster_concepts_1{ 
      "B1","B2","B3" 
      "B1" -> "B2" 
      "B1" -> "B3" 
     } 
     //A1 -> B1; 
    } 
    subgraph cluster_fkgs 
    { 
      "C1","C2","C3" 
      "C1" -> "C2" 
      "C1" -> "C3" 
    } 
    edge[ style = invis ]; 
    { A2 A3 } -> B1; 
    { B2 B3 } -> C1; 
} 

這將產生

enter image description here

節點C1錯位 - 我想這來自於嵌套集羣,但我有針對它的配方。無論如何希望它有幫助。