GAPI provides the application developer with an impressive array of facilities for
managing and drawing graphs. The full set of methods of GAPI is given in the reference
guide. The purpose of this tutorial is to quickly allow the user to handle the
basic features of GAPI.
The available methods have clear names and are easy to use. For example, if you have to
construct a new graph, simply use 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).
Namely, suppose that you want to create a graph with four nodes (labeled 1,2,3,and 4) and
four edges ((1,2),(1,3),(1,4),(2,3)).
Erasing a node or an edge is also very simple. For example, if you want to delete
vertex v2, you can do:
- Perform the following sequence of steps:
// create an empty graph called ug
node v1 = ug.new_node(1);
// add a node with identifier 1 to ug
node v2 = ug.new_node(2);
node v3 = ug.new_node(3);
node v4 = ug.new_node(4);
edge e1 = ug.new_edge(v1,v2);
// add an edge to ug
edge e2 = ug.new_edge(v1,v3);
edge e3 = ug.new_edge(v1,v4);
edge e4 = ug.new_edge(v2,v3);
- If some edges are directed, then it can be simply stated as follows.
// edge e2 is directed from v1 to v3
Identifiers associated to nodes and edges can be changed. Of course, collisions
with existing identifiers must be avoided.
// edges incident to v2 are automatically deleted
When you create a node or an edge, if you do not specify an identifier, then the
system automatically selects a non-already-used identifier and associetes it to
the new object.
// the identifier associated to v1 is changed to 84
The full set of methods of the classes of GAPI are given in the reference guide. They are
grouped into types. We distinguish among constructors and operators, access methods, update
methods, and input/output methods.
Last update : July 31, 2002
Website design by INTEGRA Sistemi, www.IntegraSistemi.it