How to make nodes overlap in Graphviz?

84 Views Asked by At

I want to make some of the nodes in my graph to overlap in the following manner:

this

I am using pygraphviz to render graphs.

So far, I have been trying to get the coordinates of the overlapping nodes and move them to the position I want, but that doesn't seem to be working.

I am quite sure that this is not possible using Graphviz, but is there any other way to do this?

1

There are 1 best solutions below

4
sroush On

Graphviz does support user-defined node coordinates, but only with the neato (neato -n) layout engine.

graph O {
  // produce this graph with:
  //   neato -n  -Tpng mygraph.gv >mygraph.png
  //   or
  //   neato -n2  -Tpng mygraph.gv >mygraph.png
  //
  //  remember, sizes are in inches, pos is in points (1/72 inch)
  //
  //  see also:
  //    http://www.graphviz.org/faq/#FaqDotWithNodeCoords
  //    http://www.graphviz.org/faq/#FaqDottyWithCoords

  big [ shape=square width=3. height=3. fixedsize=true pos="216,216" label=""]
  small_a [ shape=square width=.3 height=.3 fixedsize=true pos="144,108"
           style=filled fillcolor=white label=""]
  small_b [ shape=square width=.3 height=.3 fixedsize=true pos="244,324"
           style=filled fillcolor=white label=""]
}  

Gives:
enter image description here