How to combine graphs of different layouts into one output graph with gvpack?


let’s say we have 2 digraphs D and N as follow

digraph D {
n0 -> {n1  n2  n3} ;
digraph N {
n0 [ pos = "0,0!" ];
n1 [ pos = "2,0" ];
n2 [ pos = "2,1!" ];
n0 -> {n1  n2  n3} ;

I’m trying to pack them with gvpack and have :
on the left-hand side the D graph
on the right-hand side the N graph.

What I’ve tried so far is :

dot >
dot >
gvpack  -array_i2 >
Warning: node n1 in graph[1] N already defined
Some nodes will be renamed.

The warning is of course normal… and then

neato -s -n2 -Tsvg > pack.svg 
Warning: layout attribute is invalid except on the root graph
Error: Layout type: "" not recognized. Use one of: circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
Error: Layout was not done.  Missing layout plugins?


I edited the file by just adding layout=“neato” to the top graph

neato -s -n2 -Tsvg > pack.svg

And I have as a result :

  • How could I have a better workflow and avoid editing the file?
  • And How could I have better edges?

Thanks. (1.6 KB) (1.6 KB)

the problem with edges is linked to the fact that the label is longer due to the duplicate names…
If we handle the duplicates then everything is OK :

And I also forgot an exclamation mark for n1 : n1 [ pos = “2,0” ]; should be n1 [ pos = “2,0!” ];

Anyway, I don’t know how to resolve my main problem: a direct workflow without editing the file.

I’m not clear on the problem. What would “a better workflow” and “better edges” be? It’s unclear what “better” means. What aspect are you looking to improve?

  • if possible, remove the layout attribute from the source file. use the command line to choose an engine (dot or neato)
  • to have duplicate labels, set the label explicitly: abc [label="n0"]
  • I think the -s command line option is unnecessary when using neato -n2

Easy to automate, no hand editing.

Perfect !
The solution is to remove the layout attribute from the source file and use the right command as you suggested :

$ dot   >
$ neato >
$ gvpack  -array_i2 >
$ neato -n2 -Tsvg > pack.svg
$ chrome $(pwd)/pack.svg


no hand editing.