Beginner help: layout of nodes within clusters

I'm trying to use Graphviz for a purpose it wasn't really intended for - drawing highly detailed layout diagrams of my office network. Within my graph I'm creating a cluster for each network device. Within each cluster I'm creating nodes for each device port. For example, I have: subgraph cluster_MPLS_NLVSwitch1 { style=filled; color=lightgrey; node [style=filled; color=white, shape=box] label = "MPLS_NLVSwitch1" MPLS_NLVSwitch1_Gig_0_1 [label="Gig_0_1"] MPLS_NLVSwitch1_Gig_0_15 [label="Gig_0_15"] MPLS_NLVSwitch1_Gig_0_23 [label="Gig_0_23"] MPLS_NLVSwitch1_Gig_0_5 [label="Gig_0_5"] } subgraph cluster_c04 { style=filled; color=lightgrey; node [style=filled; color=white, shape=box] label = "c04" c04_Gig_1_0_15 [label="Gig_1_0_15"] c04_Gig_1_0_28 [label="Gig_1_0_28"] c04_Gig_1_0_29 [label="Gig_1_0_29"] c04_Gig_1_0_43 [label="Gig_1_0_43"] c04_Gig_1_0_6 [label="Gig_1_0_6"] } MPLS_NLVSwitch1_Gig_0_1 -- c04_Gig_1_0_15; to enter a couple of network devices and one connection between them. My first question is with regard to the layout of nodes within a cluster. In the c04 cluster, for example, Gig_1_0_15, Gig_1_0_28, Gig_1_0_29, Gig_1_0_43, and Gig_1_0_6 are all laid out in a row, left to right. What must I do to get them to stack vertically within cluster c04's bounding box? My second question regards the layout of nodes themselves. In my actual file I've got 34 clusters with anywhere from 1 to a couple dozen nodes in each cluster. When I run "dot" against my dot file, the resulting graphic has all of the clusters laid out in two rows. That makes for a really wide and short graphic. How can I get the clusters to spread out more, get some more height and less width? I've experimented with various combinations of mode, model, nodesep, and overlap but haven't found anything that works. Any pointers to where I can find info on this would be greatly appreciated!

In an ideal world, you could

In an ideal world, you could specify an aspect ratio per cluster and dot would try to preserve this with unconstrained nodes within clusters. Unfortunately, this isn't available. Basically, dot introduces vertical structure only when edges are present. Its main principle is that if you have an edge a -- b, node a will appear above node b in the layout. But you don't want to see these structural edges, so you would specify style=invis for them.

For even more control, you might want to change your clusters into nodes and use HTML-like labels to specify the internals, so your device ports would become cells in a table and you could provide a port attribute to connect edges to them. See http://www.graphviz.org/content/node-shapes#html for more details.

The same ideas hold at the top level. If you want more than two rows, you may need to introduce invisible edges to force some vertical structure. On the other hand, if your graph has multilple connected components, there are other ways to handle this more automatically using gvpack. If your graph has multilple components and you want more details, let me know.

Recent comments