GAPI provides algorithms to draw graphs with polygonal edges. If you want to construct a polyline drawing of a graph with GAPI, simply do the following:

• 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:
plan_undi_graph pug(ug);
draw_undi_graph dug(pug,POLYLINE);
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 of "v".
Observe that if you have strict aesthetics requirements, you can replace
draw_undi_graph dug(pug, POLYLINE);
with
draw_undi_graph dug(pug, POLYLINE_COMPACTED);
in order to reduce the total edge-length of the drawing.

Note: the current version of GDT allows to apply option POLYLINE 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.

Examples of polyline representations drawn with GAPI are shown in the following figure:

Last update : July 31, 2002
Website design by INTEGRA Sistemi, www.IntegraSistemi.it