centering child nodes

hi, first time using graphviz and i'm trying to create a tree. not a binary tree, nodes may have a different number of children.

i managed to create a simple tree like so:
digraph G{
graph [ordering="out"];
"a" -> "b";
"a" -> "c";
"b" -> "d";
"d" -> "e";
"d" -> "f";
"c" -> "g";
"c" -> "h";
"g" -> "i";
"g" -> "j";
"g" -> "k";
"h" -> "l";
"h" -> "m";
}

the tree is technically correct, but there are two problems:
1) the children nodes are not centered under the parent nodes.

for example, if you look at node d, you will see that f is directly underneath d while e is off to the left. i would like the parent node to always be centered above the children nodes, regardless of how many children nodes there are.

2) the overall image is too big. i am outputting to a pdf file, and it says the dimensions are 659 x 347 pixels. how can i shrink the output into a manageable size?

unfortunately i dont have a lot of time to learn about all of the advanced features right now, i am just looking for a quick way to accomplish this. any help is appreciated!

1) The dot layout makes no

1) The dot layout makes no attempt to center a parent node over its children. Indeed, it attempts to produce a compact drawing, which means it usually packs nodes fairly tightly together. To get  what you want, you would need a totally different layout algorithm. It's not very hard to write using gvpr.

2) You can use the size parameter to specify a maximum size in inches. The picture will be scaled down uniformly to fit.

dot -Gsize=3 -Tpng ...

will make the drawing fit in a 3inch x 3inch square.

Recent comments