I have the follow dot definition of a graph:
digraph G {
bgcolor="gray"
node [
style=filled
shape="circle"
fillcolor="green4"
penwidth="2"
color="green1"
fontcolor="white"
]
root [
shape="box"
color="white"
fontcolor="white"
label="hello"
]
AAA_1 [
label="AAA"
]
BBB_2 [
label="BBB"
]
subgraph cluster_ccc {
color=gray
fillcolor="blue"
style=filled
label="ccccc"
labelloc=b
fontcolor="white"
labeljust=l
subgraph cluster_south_a {
label="aaaaaaaaaaa"
5 [ label="" fillcolor="red" ]
6 [ label="" fillcolor="red" ]
5 -> 6
}
subgraph cluster_south_b {
label="bbbbbbbbbbb"
7 [ label="" fillcolor="red" ]
8 [ label="" fillcolor="red" ]
7 -> 8
}
}
root -> AAA_1
root -> BBB_2
AAA_1 -> 7
BBB_2 -> 5
}
Which produces the output:
The red nodes are not horizontally centered in their cluster.
It would also need to work if cluster_south_b was updated to
subgraph cluster_south_b {
label="bbbbbbbbbbbbbbbbbbbbbb"
7 [ label="" fillcolor="red" ]
8 [ label="" fillcolor="red" ]
9 [ label="" fillcolor="red" ]
10 [ label="" fillcolor="red" ]
7 -> 8
7 -> 9
8 -> 9
8 -> 10
9 -> 10
}
which produces the output of:
What comes close is adding the graph attribute nodesep=.75 just below bgcolor="gray" (that was suggested on the Graphviz forum). But manually fine-tuning that value is not a practical solution for me.
Is it possible to have them horizontally centered? If so, how?


There is no guaranteed way to center a set of nodes within a larger (wider) cluster, but this seems to work pretty well
and
Giving:

and
