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. Finally, we show how to customize the drawing according to your special requirements

*
*
If you want to construct a quasi-upward 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**). Give each edge the desired direction (**make_directed**). Suppose that the variable corresponding to the graph is named "ug". - Perform the following sequence of steps:

**list<edge> Le = ug.make_embedding_cand_expanded();**

forall (e,Le) ug.new_constraint_uncrossable_edge (e);

plan_undi_graph pug(ug);

pug.contract();

upwa_plan_undi_graph upug(pug);

draw_undi_graph dug(opug);

Operation**ug.make_embedding_cand_expanded()**finds an ordering of the edges around each node such that all edges leaving the node are consecutive, as well as all edges entering the node. Then it replaces each node "v" with two nodes "v1" and "v2" such that "v1" has only the edges entering "v" and "v2" has only the edges leaving "v"; finally, a directed dummy edge from "v1" to "v2" is added, and it is stored in the list "Le".

Cycle**forall (e,Le) ug.new_constraint_uncrossable_edge (e)**adds a set of constraints in order to avoid crossings on the edges of the list "Le" during the next step.

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**.

Operation**pug.contract()**restores the original graph by contracting previously split nodes, preserving the ordering of the edges around nodes.

Constructor**upwa_plan_undi_graph**computes a quasi-upward representation of the planarized graph, minimizing the total number of bends along edges. The name of the quasi-upward graph so obtained is "upug". Variable "upug" is an object of the class**upwa_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. The constructor has the target of using as less area as possible. 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 a quasi-upward drawing. For example, applying
**center**to node "v" returns the coordinates of the center of "v".

*
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*

- 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);**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.

Website design by INTEGRA Sistemi, www.IntegraSistemi.it