boost::graph simplified to pgRouting needs
This class gives the handling basics of a boost::graph of kind G where G: can be an undirected graph or a directed graph.
Requiremets:
A vertex class T_V
Current Available vertex classes:
An edge class T_E
Current Available edge classes:
extract_vertices function
Data obtained from postgresql is stored in A C array of pgr_edge_t type.
Data obtained from postgresql is stored in o a vector container.
Boost Graph
The code is prepared to be used for:
- boost::adjacency_list graph type
- boost::undirectedS when the graph is UNDIRECTED
- boost::bidirectionalS when the graph is DIRECTED
boost::adjacency_list
< boost::vecS,
boost::vecS,
boost::undirectedS,
Basic_vertex,
Basic_edge >
Example Usage:
For this example we will use:
Create Graph type
typedef typename
graph::Pgr_base_graph <
boost::adjacency_list <
boost::vecS,
boost::vecS,
boost::bidirectionalS,
Basic_vertex,
Basic_edge >,
Basic_vertex,
Basic_edge >
Initializing the graph
Graph initialization is for seting the Vertices of the graph.
TODO discuss if also the edges
Vector of unique vertices of the graph
There are several ways to initialize the graph
verices,
gType);
vertices.clear();
3. Initializes a graph based on the extracted vertices
gType);
4. Initializes a graph based on the extracted vertices
gType);
- Initializes an empty graph
- vertices vector size is 0
- Initializes a graph based on the vertices:
- vertices vector size is vertices.size()
- the vertices are inserted
- vertices container can be clared to free memory
- Initializes a graph based on the vertices extracted
- from edges stored on a C array
- the vertices are inserted
- Initializes a graph based on the vertices extracted
- from edges stored on a vector
- the vertices are inserted
Fill the graph
After initializing the graph with the vertices, the edges can be added.
digraph.insert_edges(my_edges, total_edges);
digraph.insert_edges(new_edges);