graphvizedge-detectiondot

How to control node placement in graphviz (i.e. avoid edge crossings)


I'm using graphviz (dot) to generate the graph you can see below. The node in the lower left corner (red ellipse) causes annoyance as its edges cross several edges of the adjacent node. Is there a way to restrain node placement to a certain area?

graph with edge crossing several other edges


Solution

  • I'm not aware of any means by which to control the placement of individual nodes. It doesn't really make sense, because in order to do that you'd need to know what the final graph will look like, yet placing one node manually would then change how the rest of the graph is rendered.

    I solved this problem by changing the order in which my nodes are defined in the .dot file, and tweaking the nodesep and ranksep attributes at the graph level. It's a process of refinement - tweaking a few things at a time until it looks right.

    You might also render the graph as SVG, then import it into Visio (or another editor) and manually rearrange the nodes you're not happy with.