PGROUTING  3.2
pgrouting::graph Namespace Reference

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

Classes

class  Pgr_base_graph
 
class  Pgr_contractionGraph
 
class  Pgr_lineGraph
 
class  Pgr_lineGraphFull
 
class  PgrCostFlowGraph
 
class  PgrDirectedChPPGraph
 
class  PgrFlowGraph
 

Typedefs

using CHDirectedGraph = Pgr_contractionGraph< boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS, CH_vertex, CH_edge > >
 
using CHUndirectedGraph = Pgr_contractionGraph< boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, CH_vertex, CH_edge > >
 

Detailed Description

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.

std::vector< T_V >

Data obtained from postgresql is stored in o a vector container.

std::vector< T_V >
extract_vertices(std::vector< pgr_edge_t >)

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, // not tested with other values
    boost::vecS, // not tested with other values
    boost::undirectedS, // USinG UNDIRECTED
    Basic_vertex, // the vertex class
    Basic_edge > // the edge class

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

size_t total_edges;
pgr_edge_t *my_edges = NULL;
pgr_get_edges(edges_sql, &my_edges, &total_tuples);
std::vector< Basic_Vertex > vertices(pgrouting::extract_vertices(my_edges));

There are several ways to initialize the graph

// 1. Initializes an empty graph
pgrouting::DirectedGraph digraph(gType);
// 2. Initializes a graph based on the vertices
verices,
gType);
vertices.clear();
3. Initializes a graph based on the extracted vertices
pgrouting::extract_vertices(my_edges, total_edges);
gType);
4. Initializes a graph based on the extracted vertices
gType);
  1. Initializes an empty graph
    • vertices vector size is 0
  2. 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
  3. Initializes a graph based on the vertices extracted
    • from edges stored on a C array
    • the vertices are inserted
  4. 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.

// inserting edges from a C array
digraph.insert_edges(my_edges, total_edges);
// adding more edges to the graph from a vector container
digraph.insert_edges(new_edges);

Typedef Documentation

◆ CHDirectedGraph

using pgrouting::graph::CHDirectedGraph = typedef Pgr_contractionGraph< boost::adjacency_list < boost::listS, boost::vecS, boost::bidirectionalS, CH_vertex, CH_edge> >

Definition at line 56 of file ch_graphs.hpp.

◆ CHUndirectedGraph

using pgrouting::graph::CHUndirectedGraph = typedef Pgr_contractionGraph < boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS, CH_vertex, CH_edge> >

Definition at line 51 of file ch_graphs.hpp.

pgr_edge_t
Definition: pgr_edge_t.h:37
pgr_get_edges
void pgr_get_edges(char *edges_sql, pgr_edge_t **edges, size_t *total_edges)
basic edge_sql
Definition: edges_input.c:711
pgrouting::DirectedGraph
graph::Pgr_base_graph< boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, Basic_vertex, Basic_edge >, Basic_vertex, Basic_edge > DirectedGraph
Definition: pgr_base_graph.hpp:192
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
pgrouting::extract_vertices
std::vector< Basic_vertex > extract_vertices(std::vector< Basic_vertex > vertices, const std::vector< pgr_edge_t > data_edges)
Definition: basic_vertex.cpp:59