oarfish
oarfish

Reputation: 4622

How can I make dot (graphviz) layout unconnected nodes vertically instead of horizontally?

I use pyreverse to create class diagrams from python code and this results in graphs like this:

enter image description here

as can be seen, some classes are not related. I would like to have the subgraphs laid out below each other so that I can include the image in a document.

Is there a simple way to modify a dot file so that disconnected parts of a graph are placed below each other?

Upvotes: 6

Views: 1578

Answers (1)

vaettchen
vaettchen

Reputation: 7659

Connect the disconnected parts with invisible edges:

digraph so
{
    node[ shape = box ];
    A[ label = "Message" ];
    B[ label = "MetaMessage" ];
    C[ label = "TrainingMessage" ];
    D[ label = "MessageBundle" ];

    A -> { B C };
    { B C } -> D[ style = invis ];
}

yields

enter image description here

Upvotes: 2

Related Questions