How to optimize the edges in some simple situations?

企业微信截图_95a979d8-96f9-471e-87d2-58d8d7407e8e

As figure 1, this dot file’s rankdir is LR. Obviously, if the rectangle is moved further down, the edge will become horizontal and more beautiful. Anyway to optimize it ?

As figure 2, the rank assignment has some problem.

please provide your source (preformatted)

(post deleted by author)

test.dot (24.1 KB)

Here is my source dot file. For example, node 33859’s rank is obviously with some errors.

  • what release of Graphviz are you using? (type dot -V )
  • what OS are you using? I’m seeing different results Linux vs. Windows. (Windows producing arguably poorer results)
  • I couldn’t recognize any oddities with node 33859 (see below), but I did see odd node placement for a few other nodes (see further below)

All the node placements seem to be “legal”, just not necessarily “pretty”. If a node can “legally” be placed in any of a range of ranks, so be it. Dot will pick a rank, but not necessarily the rank you or I would pick.
However, if you add this (undocumented) graph-level attribute to your graph, the node placement will be more consistent:

	// TBbalance - undocumented attribute
	//   see  https://gitlab.com/graphviz/graphviz/-/issues/1339
	TBbalance=min // max is other option

TBbalance is only documented here: Align rank from bottom in dot graph (#1339) · Issues · graphviz / graphviz · GitLab.
I think it may make you happier.


Actually, i use python sdk for generate dot file and the version of dot is dot - graphviz version 2.49.3 (0).
My computer’s OS is macOS.
On my computer, the node 33859 is displayed as follows
企业微信截图_bd9d0ae0-bd41-4afe-9d95-17a1551a1db7
I read the paper how graphviz assign the rank and I think it doesn’t fit the theory. (But, obviously, it is correct on your computer.)
Thank you very much for answering my question. Next, I will try the new attributs you wrote. Have a nice day.

Curiously inconsistent across computers, OSs, or something.