GAPI provides several visibility layout algorithms.
If you want to construct a standard visibility representation of a graph with GAPI, simply do the
Observe that if you have strict aesthetics requirements, you can replace
- Construct your graph by using the primitives that the class
undi_graph puts at disposal of the programmer to insert nodes
and edges (new_node and new_edge).
If some edges are directed give to them the desired direction (make_directed).
Suppose that the variable
corresponding to the graph is named "ug".
- Perform the following sequence of steps:
The meaning of such steps is the following:
Constructor plan_undi_graph performs a "planarization" of the
graph: an order is choosen for the edges around each node
trying to keep the number of crossings between edges as low as
possible. The name of the planarized graph so obtained is "pug".
Variable "pug" is an object of the class plan_undi_graph.
Constructor draw_undi_graph constructs the final drawing
by assigning each node with a position of the plane and each edge-segment
with a length. Variable "dug" is an object of the class draw_undi_graph.
- At this point variable "dug" stores all the information that is
needed to draw "ug" as an orthogonal drawing. For example, applying
center to node "v" returns the coordinates of the center
draw_undi_graph dug(pug, VISIBILITY);
draw_undi_graph dug(pug, VISIBILITY_COMPACTED);
in order to reduce the total edge-length of the drawing.
Note: the current version of GDT allows to apply option
VISIBILITY 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.
An example of a visibilty representation drawn with GAPI is shown in the following
To draw directed graphs, GAPI offers an "upward-visibility" layout model. For more
details, you can see the GAPI reference. An example of an upward-visibility drawing with a
cross, is shown in the next figure:
Last update : July 31, 2002
Website design by INTEGRA Sistemi, www.IntegraSistemi.it