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 adjac
I like @smokris' [style=invis]
trick for persuading graphviz to put things where you want them, by adding edges which affect layout but aren't visible.
Another trick is the constraint attribute, which lets you add edges which are visible but don't affect layout.
If adding a new edge messes up your graph, set [constraint=false]
on that edge: now graphviz will ignore it when placing nodes.
You could create an invisible constraint, to cause the red node to appear to the left of all other nodes.
redNode -> leftmostNode [style=invis];
Before:
After:
@Jannis, in case you're still interested in an answer to this, there is actually a way to control individual node placement - you use the "pos" attribute:
http://www.graphviz.org/doc/info/attrs.html#d:pos
As an example of this, you could write:
n [pos="3,5!"];
That would force node n
to be at precisely (3,5)
.
However, this only works with layout engines "fdp" and "neato".
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.