I have generated 2 different graphs and then combined them using gvpack into 1 file, my question is, is it possible to connect up 2 nodes using an edge across the graphs, so from the left graph to the right graph?
Yes you can add edges (and nodes, too). neato -n2
will position any “new” edges (Command Line | Graphviz)
But there are some potential problems to avoid:
- Add the edge(s) at (or near) the end of the file that Graphviz produces, just before the last brace. If the edge is added too near the beginning of the file it will interfere with the definition of one or both of the nodes. i.e. the edge might define the nodes and cancel your desired node attributes
- Your new edges might inherit unwanted attributes from the existing edge definitions, I suggest adding a subgraph
{ ... }
around everything except the root graph definition. (This might be a bit of a pain to automate.) -
neato defaults to
splines=false
. If you want a different value for the splines attribute, addsplines=whatever
either to the Root graph definition or just before the last brace of the file.
Is the addition of a subgraph you are talking about done after the 2 files have been generated and added into one using gvpack, and is it possible if you could link me or show me an example of how you add the edge using neato afterwards.
Thanks
Whoops, I was wrong about needing to add a subgraph. Gvpack already does this (see below).
Below is a graph that was produced by gvpack using a command line like this
gvpack -Glabel="out22.pdot out3.pdot" -array_ib2 out22.pdot out3.pdot >out105.pdot
The result was then hand-edited.
- to make it smaller (removed various edges)
- to add these two lines just before the closing brace:
splines=true
x2->n5 [color=green]
Off-hand, I don’t know how to use neato to add the edge. Hand editing or most any programming language can do the trick.
digraph root {
graph [bb="0,0,588.57,431.2",
label="anotherLoopIssue0.dot b786.dot",
lheight=0.23,
lp="294.29,12.4",
lwidth=2.52
];
node [label="\N"];
subgraph G {
graph [bb="",
label="",
nodesep=0.5
];
node [fixedsize=true,
fontcolor=black,
fontname=Arial,
fontsize=24,
height=1.0,
label="\N",
pos="",
width=1.0
];
edge [fontcolor=black,
fontname=Arial,
fontsize=24,
headport="",
label="",
lp="",
pos="",
style=solid,
tailport=""
];
x0 [height=<1>,
label="",
pos="128.57,332.8",
width=<1>];
x0:ne -> x0:nw [label=<1>,
lp="128.22,416.8",
pos="e,102.22,358.8 154.22,358.8 172.22,380.13 172.22,402.8 128.22,402.8 90.067,402.8 85,385.75 96.065,367.31"];
x1 [height=<1>,
label="",
pos="43.571,196.8",
width=<1>];
x0 -> x1 [label=<4>,
lp="61.223,264.8",
pos="e,41.965,232.93 96.043,316.57 80.879,307.7 64.007,295.04 54.223,278.8 47.816,268.16 44.504,255.33 42.92,243.06"];
x2 [height=<1>,
label="",
pos="128.57,60.8",
width=<1>];
x0 -> x2 [label=<9>,
lp="135.22,196.8",
pos="e,128.22,97.188 128.22,296.78 128.22,248.35 128.22,160.89 128.22,107.41"];
// removed some edges
x2 -> x1 [label=<7>,
lp="100.22,128.8",
pos="e,62.088,166.06 109.12,91.919 96.828,111.29 80.748,136.64 67.549,157.45"];
x2:sw -> x2:se [label=<0>,
lp="128.22,144.8",
pos="e,154.22,34.8 102.22,34.8 38.223,58.133 38.223,130.8 128.22,130.8 213.65,130.8 217.99,65.326 163.47,38.72"];
}
subgraph g {
graph [bb=""];
node [height="",
label="\N",
pos="",
rects="",
shape=record,
width=""
];
edge [headport="",
pos="",
tailport=""
];
subgraph cluster0 {
graph [bb="225.57,32.8,588.57,304.8"];
node [height="",
label="\N",
pos="",
rects="",
shape=record,
width=""
];
edge [headport="",
pos="",
tailport=""
];
n12 [height=0.52778,
label="<f0>|<f1>12|<f2>",
pos="270.57,59.8",
rects="234.07,41.3,254.57,78.3 254.57,41.3,285.57,78.3 285.57,41.3,307.07,78.3",
width=1.0139];
n13 [height=0.52778,
label="<f0>|<f1>13|<f2>",
pos="361.57,59.8",
rects="325.07,41.3,345.57,78.3 345.57,41.3,376.57,78.3 376.57,41.3,398.07,78.3",
width=1.0139];
n18 [height=0.52778,
label="<f0>|<f1>18|<f2>",
pos="543.57,59.8",
rects="507.07,41.3,527.57,78.3 527.57,41.3,558.57,78.3 558.57,41.3,580.07,78.3",
width=1.0139];
n2 [height=0.52778,
label="<f0>|<f1>2|<f2>",
pos="266.57,132.8",
rects="233.57,114.3,254.07,151.3 254.07,114.3,278.07,151.3 278.07,114.3,299.57,151.3",
width=0.91667];
n23 [height=0.52778,
label="<f0>|<f1>23|<f2>",
pos="452.57,59.8",
rects="416.07,41.3,436.57,78.3 436.57,41.3,467.57,78.3 467.57,41.3,489.07,78.3",
width=1.0139];
n3 [height=0.52778,
label="<f0>|<f1>3|<f2>",
pos="328.57,205.8",
rects="295.57,187.3,316.07,224.3 316.07,187.3,340.07,224.3 340.07,187.3,361.57,224.3",
width=0.91667];
n3:f0 -> n2:f1 [pos="e,266.57,150.8 305.57,186.8 305.57,167.45 279.33,171.49 269.9,160.55"];
n4 [height=0.52778,
label="<f0>|<f1>4|<f2>",
pos="351.57,132.8",
rects="318.07,114.3,338.57,151.3 338.57,114.3,363.57,151.3 363.57,114.3,385.07,151.3",
width=0.93056];
n3:f2 -> n4:f1 [pos="e,351.57,150.8 351.57,186.8 351.57,174.8 351.57,169.55 351.57,160.92"];
n5 [height=0.52778,
label="<f0>|<f1>5|<f2>",
pos="393.57,278.8",
rects="360.57,260.3,381.07,297.3 381.07,260.3,405.07,297.3 405.07,260.3,426.57,297.3",
width=0.91667];
n5:f0 -> n3:f1 [pos="e,328.57,223.8 370.57,259.8 370.57,239.44 341.77,244.97 331.87,233.51"];
n7 [height=0.52778,
label="<f0>|<f1>7|<f2>",
pos="459.57,205.8",
rects="426.57,187.3,447.07,224.3 447.07,187.3,471.07,224.3 471.07,187.3,492.57,224.3",
width=0.91667];
n5:f2 -> n7:f1 [pos="e,459.57,223.8 416.57,259.8 416.57,239.16 446.06,245.11 456.2,233.61"];
n6 [height=0.52778,
label="<f0>|<f1>6|<f2>",
pos="436.57,132.8",
rects="403.57,114.3,424.07,151.3 424.07,114.3,448.07,151.3 448.07,114.3,469.57,151.3",
width=0.91667];
n7:f0 -> n6:f1 [pos="e,436.57,150.8 436.57,186.8 436.57,174.8 436.57,169.55 436.57,160.92"];
n8 [height=0.52778,
label="<f0>|<f1>8|<f2>",
pos="520.57,132.8",
rects="487.57,114.3,508.07,151.3 508.07,114.3,532.07,151.3 532.07,114.3,553.57,151.3",
width=0.91667];
// removed more edges
}
}
///////////////////////////////////////////////////////////////////////
// new edge goes here
//////////////////////////////////////////////////////////////////////
splines=true
x2->n5 [color=green]
}
Giving: