I am creating control flow graphs. Each node contains a block of instructions. Some nodes have many instructions, some have only one. The dot layout puts huge nodes and tiny nodes on the same rank and it makes for sparse graphs that are hard to read. Here is a small example of what I am talking about:
The only problem is that I can’t put any content in there. If I add a label to the cluster, it just stretches out the cluster. It doesn’t fill it. Ideally I would want large nodes that are just the size of the contents.
If we were able to place text within the clusters, how would you size the clusters? By eyeball (manually) or programmatically? i.e. how would you determine how many invisible nodes for a given cluster?
It isn’t too hard to come up with an estimate of the height of a node based on the number of instructions it contains. Or I could even do a first pass that just creates the nodes and parses the result to get the exact measurements. Then I could create the stand-in longer clusters choosing the number of invisible nodes based on the known long node heights. Assuming that this is done conservatively in such a way that the resulting stand-in clusters are never shorter than the actual long node, I can imagine creating a base layout in .dot format, replacing the stand-in clusters with the actual long nodes, fixing up the edges, and rendering the final graph. I’m just wondering if there are some alternatives that might work better.
I would love to see something like a “rankspan” attribute for nodes that would more or less do the same thing as I would be doing manually above. I’d have to think about it a little more to specify what happens when the long node is larger than the size of internal subgraph. Maybe you could just apportion the excess height proportionally between the spanned ranks.
I’m not sure what you mean about the text-wrapping. I am manually doing text-wrapping.
The rankdir flip is an interesting idea. It won’t work in general, but clever. It is desirable to keep edges coming out of the tops and bottoms and I can use ports for that, but I would like to keep edges from going upwards (except for backedges). I’ll experiment with the multipass approach to see what I can get out of that.