[Contents] [Intro] [Reference] [Tutorial] [Question [New [Index]
Overview -> Tutorial -> Optimizing the Graph Layout

Section 2: Optimizing the Graph Layout

This tutorial section covers the following exercises:

Setting the Layout Dimensions

First you need to load a graph in daVinci by using menu
File/Open.... We suggest to use file graph_example.daVinci in the examples directory of the daVinci distribution again (refer to section 1). Afterwards, start the graph layout algorithm with menu Layout/Improve All.

Now we will modify the dimensions of the current graph visualization. This can be done with the layout dimensions dialog, available after selecting menu Options/Layout Dimensions. In the dialog you can find an option button Size (pt) to set the font size (measured in point). Change the font size to 24. You can see that the other dimensions in this window are automatically adjusted to keep the layout proportional when the nodes become smaller or larger. At this time the graph visualization is still the same, because the modification will take effect only after pressing the Apply push button of the dialog. So press this button now. In the footer area of the base window you can see a message when the new font is loaded. This may take some time. Afterwards the dialog window disappears and the graph is redrawn by using the new font size.

Select menu Options/Layout Dimensions again to set some other dimensions. First, choose 10 as the new font size. Then move the Gap Height slider to 10 by using the mouse. This dimension specifies the vertical node distance between the horizontal levels (in pixel). Maybe it is not possible for you to choose a distance of 10 by moving the slider, because the next value after 9 is 11. In this case set it to 9 and click at the right side of the slider. This will move the slider one step to the right to get a 10. Finally set the Gap Width to 10 pixel, too. To do that in another way this time, select the text entry field between the Gap Width label and the slider, delete the current setting with the backspace key and type 10. The gap width is the minimal distance between the nodes at each level. The actual distance between two nodes may be greater than this value (to get a better layout with straighter edges), but never smaller. Press the Apply button to use these settings and the graph will be redrawn much more compact.

Horizontal Fine Tuning

Now we will modify the automatically calculated graph layout with the mouse. This kind of direct manipulation is called fine tuning. To do so, select some graph node with the mouse. Then move the mouse slowly to the left and to the right by still holding down the left mouse button (this is called dragging). Be careful not to drag the node up- or downwards to the next or previous level. This will cause a vertical fine tuning which is discussed in the next exercise. By moving the mouse to the left and to the right, you can see how the node position is changed. Move the node towards its left or right neighbour node at the same level. When you have reached the minimal distance, the neighbour node is moved as well in the same direction, and so on.

We will now manually change the order of nodes at a level. Select menu Options/Layout Algorithm to open the layout algorithm dialog. Under MANUAL LAYOUT you can find three radio buttons to set the constraints of the horizontal fine tuning. The current setting is Preserve Node Order to move a touched neighbour node as well. This is what we have just seen before. Now select button Modify Node Order and press the Apply push button afterwards. Move some node again towards its left or right neighbour node. This time, when you have reached the minimal distance, both nodes will exchange their position. This operation allows you to change the order of nodes at a level, for example to eliminate obvious edge crossings by hand which have been ignored by the graph layout algorithm.

You might have noticed that by selecting the Modify Node Order constraint, the last group of buttons on the icon bar was modified, too. For more comfort, the last three radio buttons on the icon bar can also be used to set the fine tuning constraints.

[Preserve [Modify [Fixed

Buttons of the icon bar to control fine tuning

So select the last button (the one with STOP) of the base window's icon bar to set the Fixed Neighbour Nodes constraint. By moving some node, you can see that this setting protects the position of the left and right neighbour node when they are touched by a dragged node.

Vertical Fine Tuning

The last exercise of this chapter deals with vertical fine tuning, used to move a selected node to a different level. From the previous section of the tutorial you already know that daVinci generates a hierarchical layout were all edges are pointing downwards. By moving one node to a new level, the hierarchy property of the drawing might be violated. So for example, when you move a node one level downwards, then probably the children of this node need to be moved as well (and their children, and so on) to guarantee that each child node is at least one level under its parent node.

Ok, enough explanation. Just do it: Select a node, for example one at the topmost level, hold down the left mouse button and move the mouse slowly downwards. As soon as the mouse pointer reaches the center coordinate of the next level, a dynamic layout process starts to move the node to the new level and to rearrange the subgraph with the children (as it is explained above). Dynamic layout may take some time, especially when large parts of the graph need to be rearranged. So either you need to be patient or you have to order a more powerful computer. ;-)

It is possible that the total graph layout is getting worse after several vertical fine tuning steps. So start the layout algorithm to clean up that mess. You can see that daVinci keeps the nodes at their current level to preserve your vertical fine tuning operations. If you want the nodes back at their initial level after starting the layout algorithm, then you must deactivate the Keep Nodes at Levels check button (such that it is no longer highlighted in red) in the layout algorithm dialog, available after selecting menu Options/Layout Algorithm. Do not forget to press the Apply button in the dialog to activate this new setting!

End of section 2
Go back to the Tutorial Overview


daVinci V2.1 Online Documentation - Page update: June 15, 1998