2012-02-01 16 views
6

ボックスが横に表示されることがありますか、縦に表示されることがありますか? (related question参照)。ここでボックスを横に並べ、次に縦に並べる

は、私が取得していますコードと出力されます:

コード:

/** 
** Diagram representing the Simulator Engine 
**/ 
digraph G { 
     graph [ 
      rankdir = "TB" 
     ]; 

     /** 
     ** The simulator engine rectangle 
     **/ 
    subgraph cluster_simulator_engine { 
     style=filled; 
     color=lightgrey; 
     node [style=filled,color=white]; 
     label = "Simulator Engine"; 

       /** 
       ** The first topology 
       **/ 
       subgraph cluster_T1 { 
         color=white; 
         node [style=filled]; 

         /** 
         ** The n^th neuron 
         **/ 
         subgraph cluster_T1_N3 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron n"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N3_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N3_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N3_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 

         /** 
         ** The second neuron 
         **/ 
         subgraph cluster_T1_N2 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 2"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N2_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N2_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N2_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 


         /** 
         ** The third neuron 
         **/ 
         subgraph cluster_T1_N1 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 1"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N1_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N1_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N1_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 


         label = "Topology 1"; 
       } 

       /** 
       ** The second topology 
       **/ 
       subgraph cluster_T2 { 
         color=white; 
         node [style=filled]; 

         /** 
         ** The n^th neuron 
         **/ 
         subgraph cluster_T2_N3 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron n"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N3_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N3_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N3_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 

         /** 
         ** The second neuron 
         **/ 
         subgraph cluster_T2_N2 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 2"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N2_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N2_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N2_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 


         /** 
         ** The third neuron 
         **/ 
         subgraph cluster_T2_N1 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 1"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N1_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N1_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N1_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           /*"T1_N1_S3" -> "T1_N1_S2" [style=invis];*/ 
         } 


         label = "Topology 2"; 
       } 

    } 

} 

出力:

First Diagram

は明らかに、これはあまりにも長いです。私が望むのは、それぞれのシナプスを独自の線に移動することです(Graphvizの専門用語では「ランク」と呼ばれています)。明らかに、これを行う方法はありませんが、trickがあります。したがって、私は上記の同じコードを取るので、

コードのような目に見えないエッジを紹介:

/** 
** Diagram representing the Simulator Engine 
**/ 
digraph G { 
     graph [ 
      rankdir = "TB" 
     ]; 

     /** 
     ** The simulator engine rectangle 
     **/ 
    subgraph cluster_simulator_engine { 
     style=filled; 
     color=lightgrey; 
     node [style=filled,color=white]; 
     label = "Simulator Engine"; 

       /** 
       ** The first topology 
       **/ 
       subgraph cluster_T1 { 
         color=white; 
         node [style=filled]; 

         /** 
         ** The n^th neuron 
         **/ 
         subgraph cluster_T1_N3 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron n"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N3_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N3_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N3_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T1_N3_S1" -> "T1_N3_S2" [style=invis]; 
           "T1_N3_S2" -> "T1_N3_S3" [style=invis]; 
         } 

         /** 
         ** The second neuron 
         **/ 
         subgraph cluster_T1_N2 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 2"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N2_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N2_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N2_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T1_N2_S2" -> "T1_N2_S3" [style=invis]; 
           "T1_N2_S1" -> "T1_N2_S2" [style=invis]; 
         } 


         /** 
         ** The third neuron 
         **/ 
         subgraph cluster_T1_N1 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 1"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T1_N1_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T1_N1_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T1_N1_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T1_N1_S1" -> "T1_N1_S2" [style=invis]; 
           "T1_N1_S2" -> "T1_N1_S3" [style=invis]; 
         } 


         label = "Topology 1"; 
       } 

       /** 
       ** The second topology 
       **/ 
       subgraph cluster_T2 { 
         color=white; 
         node [style=filled]; 

         /** 
         ** The n^th neuron 
         **/ 
         subgraph cluster_T2_N3 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron n"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N3_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N3_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N3_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T2_N3_S1" -> "T2_N3_S2" [style=invis]; 
           "T2_N3_S2" -> "T2_N3_S3" [style=invis]; 
         } 

         /** 
         ** The second neuron 
         **/ 
         subgraph cluster_T2_N2 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 2"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N2_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N2_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N2_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T2_N2_S1" -> "T2_N2_S2" [style=invis]; 
           "T2_N2_S2" -> "T2_N2_S3" [style=invis]; 
         } 


         /** 
         ** The third neuron 
         **/ 
         subgraph cluster_T2_N1 { 
           color=lightgrey; 
           node [style=filled]; 
           label = "Neuron 1"; 

           /** 
           ** The n^th synapse 
           **/ 
           "T2_N1_S3" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse n" 
           ]; 

           /** 
           ** The second synapse 
           **/ 
           "T2_N1_S2" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 2" 
           ]; 

           /** 
           ** The first synapse 
           **/ 
           "T2_N1_S1" [ 
            style=filled 
            shape=box 
            color=white 
            label="Synapse 1" 
           ]; 

           "T2_N1_S1" -> "T2_N1_S2" [style=invis]; 
           "T2_N1_S2" -> "T2_N1_S3" [style=invis]; 
         } 


         label = "Topology 2"; 
       } 

    } 

} 

をし、出力は今より魅力的に見えます。

出力: Second smaller diagram

しかし、今シナプスボックスの間に大きなギャップがあります。 nodesep=0.1またはlen=0.1を設定しても効果はありません。誰でもこの問題を解決する方法やこれを再設計する方法を教えてもらえますか?

注:誰かが私が1から2へ行く理由が不思議であれば、そこに楕円を描こうとしているからですが、私はそれをどうするかわかりません。それに。それはあなたが探しているranksep

答えて

8

- グラフの属性に次の行を追加しますドットで

ranksep = 0.1 

が、これはインチで、希望順位の分離を提供します。これは、 の1つのランクのノードの底部と次のノードの上端との間の最小垂直距離です。