GraphViz: how to connect a node to the containing subgraph
dot, graphviz, subgraph
Solution
you will need some scaffolding i.e. invisible node (and maybe edges) e.g.:
digraph top {
compound=true
node[shape=rectangle]
subgraph cluster1 {
a->{b c}
}
c->d
d->b[lhead=cluster1]
ca[shape=point height=0] // make ca invisible
a->ca:n[dir=back ltail=cluster1] // by drawing the arrow backward we get more control of the layout, n and s compass make the edge go smooth when enter and exiting ca
ca:s->c[dir=none] // no arrow on the tail part
}
rendered on viz-js.com:
Problem
I just learned how to connect nodes and subgraphs here on Stackoverflow. However, I want to connect a node to the containing subgraph: ``` digraph G { compound=true; subgraph cluster0 { a -> b; a -> c; c -> {a b c} [lhead=cluster0]; } c -> d; d -> {a b c} [lhead=cluster0]; } ``` A quick sketch what I mean: I want to connect `d -> {a b c}`, but for clarity reasons, I don't want to draw three different arrows, but just one arrow to the grouping of nodes. One way to do that is only list one arrow, like `d -> a`. That works, but is there a way to "collapse" three arrows into one when the head points to a cluster? However, `c -> {a b c}` is not possible to point to a cluster, because `c` is part of that cluster. Is there a way to go around this?