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

Hi,

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

digraph D {
layout="dot"
n0 -> {n1  n2  n3} ;
}
digraph N {
layout="neato"
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 D.dot > D-o.dot
dot N.dot > N-o.dot
gvpack  -array_i2 D-o.dot N-o.dot > pack.dot
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  pack.dot -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?

cp pack.dot pack2.dot

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

neato -s -n2 pack2.dot -Tsvg > pack.svg

And I have as a result :
pack

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

Thanks.
pack.dot (1.6 KB)
pack2.dot (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 :
no-duplicate-names

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 pack.dot 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 D.dot   > D-o.dot
$ neato N.dot > N-o.dot
$ gvpack  -array_i2 D-o.dot N-o.dot > pack.dot
$ neato -n2  pack.dot -Tsvg > pack.svg
$ chrome $(pwd)/pack.svg

ok

no hand editing.

Thanks!