![]() |
aGrUM
0.13.0
|
The basic idea of the implementation of graphs in aGrUM is to leave it "as pure as possible". Hence graphs consist of integers (gum::NodeId) and binary relations between them (Edge, Arc).
Precisely a graph contains a compact representation of a set of gum::NodeId, and can contain a set of gum::Arc and a set of gum::Edge.
In aGrUM,
(as shown in the inheritance diagram for gum::MixedGraph, the class hierarchy for graphs in aGrUM uses multiple inheritance.)
This pattern of inheritance allows aGrUM to have a quite standardized API for all basic operations in graphs: manipulating and iterating over nodes, edges and arcs.
Such representation of graphs has two major drawbacks that aGrUM has to face:
For aGrUM, each node has (is) an id. IDs begin from 1 (id>0).
For the uniqueness of ids, addNode() in NodeGraphPart contains an internal idFactory which guarantees this property.
There are two ways to bypass the idFactory :
Good programmers should treat with respect the idFactory.
gum::NodeSet, gum::EdgeSet and gum::ArcSet have their own iterators (see gum::NodeSetIterator etc.). However aGrUM gives specialized iterators for graphs. These iterators are herited from the different 3 graphs part and may be (or not) a typedef for set iterators. We encourage to use these iterators when iterating on a graph.
For a graph gr
of type G
(G
is gum::DiGraph, gum::DAG, gum::UndiGraph or gum::MixedGraph, etc.) :
Properties are the way to put (dynamic) informations within nodes, edges and arcs. Properties are just HashTable in which keys are gum::NodeId, Edge or Arc. NodeProperty, ArcProperty and EdgeProperty are the names of these classes.
Equivalently, you could have written :
Here is a code for searching directed pathin a DiGraph" g from gum::NodeId n1 to gum::NodeId n2.