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
If you have strict performance requirements, then you can customize the simple
piece of code shown above to obtain drawings that are
slightly worse either in terms of number of bends along edges or in terms
of global area occupied by the drawing. On the other hand you will have
better time performance. GDT offers several facilities to explore the
performance/effectiveness trade-off.
For example, if you accept to have more bends that those that are strictly
needed, you can replace
Note: the current version of GDT allows to apply option
PLAN_ORTH_QUICK only to graphs that are biconnected and
whose nodes have at most four incident edges.
A graph is biconnected if the removal of one node is not
sufficient to cut it into two (or more) disconnected pieces.
As another example, if you accept to have a larger area than the one
that is strictly needed, you can replace
The same graph drawn with the default algorithm is as follows
GDT offers other alternatives to FAST_COMPACTION allowing to choose different
trade-offs between performance and aesthetics. Namely, FAST_COMPACTION_REFINED,
SLOW_COMPACTION, and SLOW_COMPACTION_REFINED (default option).
If aesthetics are more important than performance
If you have strict aesthetics requirements, then you can customize the simple
piece of code shown above to obtain drawings that are much
better in terms of number of bends along edges.
On the other hand you will have worse time performance.
For example, you can replace
An orthogonal drawing constructed with option PLAN_ORTH_SLOW of the same graph
of a previous figure is shown below.
Note: the current version of GDT allows to apply option
PLAN_ORTH_SLOW only to graphs that are biconnected.
A graph is biconnected if the removal of one node is not
sufficient to cut it into two (or more) disconnected pieces.
Note: option PLAN_ORTH_SLOW causes the invocation of a branch and
bound algorithm, that is potentially exponential in time requirement.
This makes it unsuitable for graphs with more that 100 nodes.
Drawing compaction
Several strategies are available for compacting orthogonal drawings. They have
assigned constants:
orth_plan_undi_graph opug(pug);
with
orth_plan_undi_graph opug(pug, PLAN_ORTH_QUICK);
This replaces the default algorithm for orthogonalization with a
faster one.
draw_undi_graph dug(opug);
with
draw_undi_graph dug(opug, FAST_COMPACTION);
This replaces the default algorithm used in the last step with a faster one.
An example of orthogonal drawing constructed with the FAST_COMPACTION option is
shown in the following figure.
orth_plan_undi_graph opug(pug);
with
orth_plan_undi_graph opug(pug, PLAN_ORTH_SLOW);
This replaces the default algorithm for orthogonalization with a
more accurate one.
FAST_COMPACTION,
If no specification is given, then
compaction SLOW_REGULAR_COMPACTION_2_REFINED is applied as a default.
If you want to force GDtoolkit to use a certain
compaction strategy, different from the default one, you have to specify it as follows:
FAST_COMPACTION_REFINED,
SLOW_COMPACTION,
SLOW_COMPACTION_REFINED,
FAST_REGULAR_COMPACTION_1,
SLOW_REGULAR_COMPACTION_1,
FAST_REGULAR_COMPACTION_2,
SLOW_REGULAR_COMPACTION_2,
FAST_REGULAR_COMPACTION_1_REFINED,
SLOW_REGULAR_COMPACTION_1_REFINED,
FAST_REGULAR_COMPACTION_2_REFINED, and
SLOW_REGULAR_COMPACTION_2_REFINED.
plan_undi_graph pug(ug);
In this case BLAG will use the compaction strategy SLOW_COMPACTION.
Usually, the best strategies,
from the aesthetics point of view, are SLOW_REGULAR_COMPACTION_1_REFINED and
SLOW_REGULAR_COMPACTION_2_REFINED. On the other hand they
are more time consuming than the others. They are strongly recommended
for applications where having very compact drawings is a strict requirement.
orth_plan_undi_graph opug(pug);
draw_undi_graph dug(opug,SLOW_COMPACTION);
(Animation, bends smoothed) |