0

I am trying to force the nodes to have a specified position in the graph. While doing so, the different sub-graphs are not aligned properly. The code to generate this graph is :

digraph {
rankdir=LR;
labeljust="l";

subgraph cluster0{

label="t=0" 


n_3_0_0[label="192.168.8.6"
    pos="15,12!"    
    ];
n_3_0_1[label="192.168.8.3"
    pos="10,10!"    
    ];

 n_3_0_0 -> n_3_0_1 ;
 n_3_0_1 -> n_3_0_0 ;
};

subgraph cluster1{

label="t=5"     

n_3_1_0[label="192.168.8.6"
    pos="15,12!"    
    ];
n_3_1_1[label="192.168.8.3"
    pos="10,10!"    
    ];
n_3_1_2[label="192.168.8.9"
    pos="10,12!"    
    ];

 n_3_1_0 -> n_3_1_1 ;
 n_3_1_1 -> n_3_1_0 ;
};


subgraph cluster2{

label="t=10" 

n_3_2_0[label="192.168.8.6"
    pos="14,10!"    
    ];
n_3_2_1[label="192.168.8.3"
    pos="10,10!"    
    ];
n_3_2_2[label="192.168.8.9"
    pos="15,11!"    
    ];
n_3_2_3[label="192.168.8.8"
    pos="18,12!"    
    ];

 n_3_2_0 -> n_3_2_1 ;

 n_3_2_2 -> n_3_2_3 ;
 n_3_2_1 -> n_3_2_0 ;
 n_3_2_3 -> n_3_2_2 ;
};

}

I compiled this code by forcing the node position:

dot -Kfdp -n -Tpng -o sample.png test2.dot

The output graph is: http://imageshack.us/photo/my-images/826/samplebg.png/ The problem with the output I got is: 1. the subgraph are NOT displayed in sequence of t=0, t-5, t=10... 2. the subgraph are NOT aligned to left.

I need to have output graph like this: http://imageshack.us/photo/my-images/253/needed.png/

Thnak You.

bdur
  • 341
  • 1
  • 8
  • 17

1 Answers1

0

Since you already precalculated the positions of all the nodes, you don't really need fdp - you just nead a layout which respects the pos attribute.

So you could generate the output like this:

neato -Tpng sourcedot.gv -O

But you'd have to adjust node positions before that, in order to have the subgraphs correctly stacked and not super-posed:

digraph {
rankdir=LR;
labeljust="l";

subgraph cluster0{
label="t=0"
n_3_0_0[label="192.168.8.6"
    pos="15,4!"
    ];
n_3_0_1[label="192.168.8.3"
    pos="10,2!"
    ];

 n_3_0_0 -> n_3_0_1 ;
 n_3_0_1 -> n_3_0_0 ;
};

subgraph cluster1{
label="t=5"
n_3_1_0[label="192.168.8.6"
    pos="15,7!"
    ];
n_3_1_1[label="192.168.8.3"
    pos="10,5!"
    ];
n_3_1_2[label="192.168.8.9"
    pos="10,7!"
    ];

 n_3_1_0 -> n_3_1_1 ;
 n_3_1_1 -> n_3_1_0 ;
};


subgraph cluster2{
label="t=10"
n_3_2_0[label="192.168.8.6"
    pos="14,8!"
    ];
n_3_2_1[label="192.168.8.3"
    pos="10,8!"
    ];
n_3_2_2[label="192.168.8.9"
    pos="15,9!"
    ];
n_3_2_3[label="192.168.8.8"
    pos="18,10!"
    ];

 n_3_2_0 -> n_3_2_1 ;

 n_3_2_2 -> n_3_2_3 ;
 n_3_2_1 -> n_3_2_0 ;
 n_3_2_3 -> n_3_2_2 ;
};

}

Resulting in

enter image description here (Some minor adjustments still needed for the label of the middle subgraph)

Or just use dot and let it align the nodes, too:

enter image description here

marapet
  • 54,856
  • 12
  • 170
  • 184
  • I need the first graph that you have shown above. But I am not able to generate it. I compiled with naeto and I can get something like this: http://imageshack.us/f/833/sourcedotgv.png/ – bdur Sep 28 '12 at 09:21
  • What version of graphviz are you using? You may need to update – marapet Sep 28 '12 at 11:05
  • my version of graphviz is 2.26.3. I tried to install graphviz version 2.29, which requires libgraphviz4(>=2.18). And I could not get a way to install libgraphviz4 in ubuntu12.04 where it have conflict with 'libcdt4' – bdur Oct 01 '12 at 08:23
  • I use 2.29 which creates the above output. So it looks like the differences in the output are due to the difference of the graphviz version. Sorry I can't help with ubuntu install issues. – marapet Oct 01 '12 at 08:28
  • I completely removed the older version of graphViz from ubuntu (libcdt4 and libpathplan also removed). Then ran those commands: sudo apt-add-repository ppa:dperry/ppa-graphviz-test , sudo apt-get update , sudo apt-get install graphviz Finally I could install graphviz 2.29. Since, graphviz 2.29 is not stable version, we have to go through these unusual steps. More information in: http://askubuntu.com/questions/196230/installing-graphviz-2-29-in-12-04 – bdur Oct 04 '12 at 07:37