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
upwa_plan_undi_graph upug(pug);
with
upwa_plan_undi_graph upug(pug, PLAN_UPWARD_SLOW);
This replaces the default algorithm for quasi-upward with a
more accurate one.
A quasi-upward drawing constructed with option PLAN_UPWARD_SLOW of the same graph
of a previous figure is shown below.
Note: the current version of GDT allows to apply option
PLAN_UPWARD_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_UPWARD_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 customization
If you need to customize your drawing, then you can exploit the
capability of GDT in handling user-specified constraints.
For example, if you want that all the nodes of a certain set (that, for example, are the
"boundary" of your application)
are drawn on the border of the polygon surrounding the drawing (external
face) then you can do the following steps:
- Suppose that "ug" is your graph and that "Le" is the list of
the nodes of the above set.
First, you have to perform:
ug.new_constraint_same_face_node(Le,c)
Where "c" is an integer label that you use to denote the face where
the nodes in "Le" will be placed.
- Perform the following sequence of steps:
plan_undi_graph pug(ug);
Determine a face "f" of "pug" containing all the nodes in "Le";
upwa_plan_undi_graph upug(pug,f);
draw_undi_graph dug(upug);
During the execution of plan_undi_graph, the constraint
is taken into account.
Once "pug" is computed, "f" can be determined by simply
scanning the faces containing the nodes of "Le".
For example you can exploit method node_belongs_to_face
that is offered by class plan_undi_graph.
- At this point variable "dug" stores all the information that is
needed to draw "ug" as a quasi-upward drawing with the nodes in "Le"
on the external face.
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.
Last update : July 31, 2002
Website design by INTEGRA Sistemi, www.IntegraSistemi.it