0

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?

albert
  • 8,285
  • 3
  • 19
  • 32
shasha
  • 1
  • 1

1 Answers1

0

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

sroush
  • 5,375
  • 2
  • 5
  • 11
  • Is it not possible to do this with the dot engine? there are some other components of my graph that require dot. – shasha Feb 27 '23 at 21:44
  • run the **dot** engine, then programmatically or manually add/reposition the overlapping nodes, then run the **neato** engine. All with Python, if you like. – sroush Feb 27 '23 at 23:13
  • Thank you! Is there any documentation or tutorial for how I can do this? – shasha Feb 28 '23 at 00:05
  • I suggest you re-ask that question on the Graphviz forum (https://forum.graphviz.org/) – sroush Feb 28 '23 at 01:06