First, we present a simple strategy, suitable for beginners (but still powerful enough to cover several applications). Second, we show how to work if performance is more important than aesthetics. Third, we describe how to behave if aesthetics are more important than performance. Fourth, we show how several choices are available for constructing drawings that are more or less compact. Fifth, we show how to customize the drawing according to your special requirements. Finally, we show how to deal with dynamic orthogonal drawing.
If you want to construct an orthogonal drawing of a graph with GAPI, simply do the following:
If performance is more important than aesthetics
The same graph drawn with the default algorithm is as follows
If aesthetics are more important than performance
Several strategies are available for compacting orthogonal drawings. They have assigned constants:
As another example, if you want to emphasize an edge "e" that for some reason is expecially important, then you maight want to preserve it to have crossings and maybe to have bends. This is done very easily by performing ug.new_constraint_uncrossable_edge(e) and/or ug.new_constraint_number_of_bends_on_edge(e,NONE) before performing the planarization step.
You can also specify the width and the height of each node, by simply using the following commands ug.new_constraint_node_width(v,width) and/or ug.new_constraint_node_height(v,height) before performing any orthogonal layout algorithm. What follows is an example of orthogonal drawing in which we have set the width and the height of node 8 both equal to 1, and the width and the height of node 2 equal to 1 and equal to 3, respectively. The length are in terms of integer grid points, and the width and the height of any node are always equal to 0 if not specified otherwise.
(Animation, bends smoothed) |