Uko
Uko

Reputation: 13386

Display nodes below parent without taking ranks to account

I'm making sorta super simplified class diagram in language. The diagram contains only simple nodes with class names, inheritance and aggregation.

In order to have a specific style for inheritance edges, and to display children classes below their parent, I use this setup:

subgraph inheritance {
    edge[dir="back"; arrowtail="empty"; arrowsize="1.75"];
    color=white;

    subgraph clusterExpression{
        Expression -> VariableExpression;
        Expression -> AssignmentExpression;

Everything works fine, but when I have a lot of subclasses my diagram becomes really wide. I don't care about subclasses being on the same level or not.

Is there a way to display all subclasses below superclass but in most compact way? Instead of this: enter image description here

I want to get something like this: enter image description here

Upvotes: 1

Views: 531

Answers (1)

marapet
marapet

Reputation: 56466

You may try the graphviz tool called unflatten :

unflatten is a preprocessor to dot that is used to improve the aspect ratio of graphs having many leaves or disconnected nodes. The usual layout for such a graph is generally very wide or tall. unflatten inserts invisible edges or adjusts the minlen on edges to improve layout compaction.

You can pipe it into your command line - see these answers for examples.

Upvotes: 2

Related Questions