PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E > Class Template Reference

#include "pgr_contractionGraph.hpp"

Inheritance diagram for pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >:
pgrouting::graph::Pgr_base_graph< G, T_V, T_E >

Public Types

typedef boost::graph_traits< G >
::degree_size_type 
degree_size_type
 
typedef boost::graph_traits< G >
::edge_descriptor 
E
 
typedef boost::graph_traits< G >
::edge_iterator 
E_i
 
typedef boost::graph_traits< G >
::in_edge_iterator 
EI_i
 
typedef boost::graph_traits< G >
::out_edge_iterator 
EO_i
 
typedef boost::graph_traits< G >
::vertex_descriptor 
V
 
typedef boost::graph_traits< G >
::vertex_iterator 
V_i
 
Graph related types
Type boost meaning pgRouting meaning
G boost::adjacency_list Graph
V vertex_descriptor Think of it as local ID of a vertex
E edge_descriptor Think of it as local ID of an edge
V_i vertex_iterator To cycle the vertices of the Graph
E_i edge_iterator To cycle the edges of the Graph
EO_i out_edge_iterator To cycle the out going edges of a vertex
EI_i in_edge_iterator To cycle the in coming edges of a vertex (only in bidirectional graphs)
typedef G B_G
 
typedef T_E G_T_E
 
typedef boost::graph_traits< G >
::vertices_size_type 
vertices_size_type
 
typedef boost::graph_traits< G >
::edges_size_type 
edges_size_type
 
Id handling related types
Type Meaning pgRouting Meaning
id_to_V maps id -> V given an id store the V
LI Left Iterator iterates over id_to_V
typedef std::map< int64_t, Vid_to_V
 
typedef id_to_V::const_iterator LI
 

Public Member Functions

 Pgr_contractionGraph (graphType gtype)
 Prepares the graph to be of type gtype More...
 
void add_contracted_edge_vertices (V v, T_E &e)
 add the contracted vertices of an edge e to the vertex v More...
 
void add_shortcut (const T_E &edge)
 add edges(shortuct) to the graph during contraction More...
 
Identifiers< Vfind_adjacent_vertices (V v) const
 get the vertex descriptors of adjacent vertices of v More...
 
Identifiers< int64_t > get_changed_vertices ()
 vertices with at least one contracted vertex More...
 
std::vector< int64_t > get_contracted_vertices (int64_t vid)
 get the contracted vertex ids of a given vertex in array format More...
 
int64_t get_edge_id (V from, V to, double &distance) const
 
std::vector< int64_t > get_ids (Identifiers< int64_t > boost_ids) const
 
E get_min_cost_edge (V source, V destination)
 get the edge with minimum cost between two vertices More...
 
void graph_add_edge (const T_E &edge)
 
void graph_add_edge (const T &edge)
 
degree_size_type in_degree_from_vertex (V vertex, V neighbor)
 The number of edges from neighbor to vertex. More...
 
size_t num_vertices () const
 
degree_size_type out_degree_to_vertex (V vertex, V neighbor)
 The number of edges from vertex to neighbor. More...
 
void print_graph (std::ostringstream &log)
 print the graph with contracted vertices of all vertices and edges More...
 
Insert edges
void insert_edges (const T *edges, int64_t count)
 Inserts count edges of type T into the graph. More...
 
void insert_edges (const std::vector< T > &edges)
 Inserts count edges of type pgr_edge_t into the graph. More...
 
boost wrappers with original id
degree_size_type out_degree (int64_t vertex_id) const
 get the out-degree of a vertex More...
 
degree_size_type in_degree (int64_t vertex_id) const
 
V get_V (const T_V &vertex)
 get the vertex descriptor of the vertex More...
 
V get_V (int64_t vid) const
 get the vertex descriptor of the vid More...
 
bool has_vertex (int64_t vid) const
 True when vid is in the graph. More...
 
boost wrappers with V
degree_size_type out_degree (V &v) const
 out degree of a vertex More...
 
degree_size_type in_degree (V &v) const
 in degree of a vertex More...
 
T_E & operator[] (E e_idx)
 
const T_E & operator[] (E e_idx) const
 
T_V & operator[] (V v_idx)
 
const T_V & operator[] (V v_idx) const
 
V source (E e_idx) const
 
V target (E e_idx) const
 
V adjacent (V v_idx, E e_idx) const
 
to be or not to be
bool is_directed () const
 
bool is_undirected () const
 
bool is_source (V v_idx, E e_idx) const
 
bool is_target (V v_idx, E e_idx) const
 
edge disconection/reconnection
void disconnect_edge (int64_t p_from, int64_t p_to)
 Disconnects all edges from p_from to p_to. More...
 
void disconnect_out_going_edge (int64_t vertex_id, int64_t edge_id)
 Disconnects the outgoing edges of a vertex. More...
 
void disconnect_vertex (int64_t p_vertex)
 Disconnects all incoming and outgoing edges from the vertex. More...
 
void disconnect_vertex (V vertex)
 
void restore_graph ()
 Reconnects all edges that were removed. More...
 

Static Public Member Functions

static bool compareById (const T_E &edge1, const T_E &edge2)
 Binary function that accepts two elements , and returns a value convertible to bool. More...
 

Public Attributes

Identifiers< Vremoved_vertices
 
std::vector< T_E > shortcuts
 
The Graph
graph
 The graph. More...
 
size_t m_num_vertices
 local count. More...
 
graphType m_gType
 type (DIRECTED or UNDIRECTED) More...
 
Id mapping handling
id_to_V vertices_map
 id -> graph id More...
 
Graph Modification
std::deque< T_E > removed_edges
 Used for storing the removed_edges. More...
 

Detailed Description

template<class G, typename T_V, typename T_E>
class pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >

Definition at line 46 of file pgr_contractionGraph.hpp.

Member Typedef Documentation

typedef G pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::B_G
inherited

Definition at line 273 of file pgr_base_graph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::degree_size_type pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::degree_size_type

Definition at line 73 of file pgr_contractionGraph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::edge_descriptor pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::E

Definition at line 67 of file pgr_contractionGraph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::edge_iterator pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::E_i

Definition at line 69 of file pgr_contractionGraph.hpp.

typedef boost::graph_traits< G >::edges_size_type pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::edges_size_type
inherited

Definition at line 285 of file pgr_base_graph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::in_edge_iterator pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::EI_i

Definition at line 71 of file pgr_contractionGraph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::out_edge_iterator pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::EO_i

Definition at line 70 of file pgr_contractionGraph.hpp.

typedef T_E pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::G_T_E
inherited

Definition at line 274 of file pgr_base_graph.hpp.

typedef std::map< int64_t, V > pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::id_to_V
inherited

Definition at line 299 of file pgr_base_graph.hpp.

typedef id_to_V::const_iterator pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::LI
inherited

Definition at line 300 of file pgr_base_graph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::vertex_descriptor pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::V

Definition at line 66 of file pgr_contractionGraph.hpp.

template<class G , typename T_V , typename T_E >
typedef boost::graph_traits< G >::vertex_iterator pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::V_i

Definition at line 68 of file pgr_contractionGraph.hpp.

typedef boost::graph_traits< G >::vertices_size_type pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::vertices_size_type
inherited

Definition at line 283 of file pgr_base_graph.hpp.

Constructor & Destructor Documentation

template<class G , typename T_V , typename T_E >
pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::Pgr_contractionGraph ( graphType  gtype)
inlineexplicit

Prepares the graph to be of type gtype

Definition at line 88 of file pgr_contractionGraph.hpp.

Member Function Documentation

template<class G , typename T_V , typename T_E >
void pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::add_contracted_edge_vertices ( V  v,
T_E &  e 
)
inline

add the contracted vertices of an edge e to the vertex v

Parameters
[in]vvertex_descriptor
[in]eEdge of type T_E

Definition at line 250 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph.

template<class G , typename T_V , typename T_E >
void pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::add_shortcut ( const T_E &  edge)
inline

add edges(shortuct) to the graph during contraction

a -> b -> c

a -> c

edge (a, c) is a new edge e e.contracted_vertices = b + b.contracted vertices b is "removed" disconnected from the graph

  • by removing all edges to/from b
Parameters
[in]edgeof type T_E is to be added

Definition at line 273 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::get_V(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph, pgassert, pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::shortcuts, and pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::vertices_map.

template<class G , typename T_V , typename T_E >
static bool pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::compareById ( const T_E &  edge1,
const T_E &  edge2 
)
inlinestatic

Binary function that accepts two elements , and returns a value convertible to bool.

Used as a compare function to sort the edges in increasing order of edge id

Definition at line 81 of file pgr_contractionGraph.hpp.

void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::disconnect_edge ( int64_t  p_from,
int64_t  p_to 
)
inherited

Disconnects all edges from p_from to p_to.

  • No edge is disconnected if the vertices id's do not exist in the graph
  • All removed edges are stored for future reinsertion
  • All parallel edges are disconnected (automatically by boost)
disconnectEdgeUndirected.png
disconnect_edge(2,3) on an UNDIRECTED graph
disconnectEdgeDirected.png
disconnect_edge(2,3) on a DIRECTED graph
Parameters
[in]p_fromoriginal vertex id of the starting point of the edge
[in]p_tooriginal vertex id of the ending point of the edge
void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::disconnect_out_going_edge ( int64_t  vertex_id,
int64_t  edge_id 
)
inherited

Disconnects the outgoing edges of a vertex.

  • No edge is disconnected if it doesn't exist in the graph
  • Removed edges are stored for future reinsertion
  • all outgoing edges with the edge_id are removed if they exist
Parameters
[in]vertex_idoriginal vertex
[in]edge_idoriginal edge_id
void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::disconnect_vertex ( int64_t  p_vertex)
inherited

Disconnects all incoming and outgoing edges from the vertex.

boost::graph doesn't recommend th to insert/remove vertices, so a vertex removal is simulated by disconnecting the vertex from the graph

  • No edge is disconnected if the vertices id's do not exist in the graph
  • All removed edges are stored for future reinsertion
  • All parallel edges are disconnected (automatically by boost)
disconnectVertexUndirected.png
disconnect_vertex(2) on an UNDIRECTED graph
disconnectVertexDirected.png
disconnect_vertex(2) on a DIRECTED graph
Parameters
[in]p_vertexoriginal vertex id of the starting point of the edge
void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::disconnect_vertex ( V  vertex)
inherited
template<class G , typename T_V , typename T_E >
Identifiers<V> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::find_adjacent_vertices ( V  v) const
inline

get the vertex descriptors of adjacent vertices of v

Parameters
[in]vvertex_descriptor
Returns
Identifiers<V>: The set of vertex descriptors adjacent to the given vertex v

Definition at line 96 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::adjacent(), and pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph.

template<class G , typename T_V , typename T_E >
Identifiers<int64_t> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::get_changed_vertices ( )
inline

vertices with at least one contracted vertex

Returns
The vids Identifiers with at least one contracted vertex

Definition at line 128 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph, Identifiers< T >::has(), and pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::removed_vertices.

template<class G , typename T_V , typename T_E >
std::vector<int64_t> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::get_contracted_vertices ( int64_t  vid)
inline

get the contracted vertex ids of a given vertex in array format

Parameters
[in]vidvertex_id
Returns
ids of contracted_vertices

Definition at line 230 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::get_V(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph, and pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::has_vertex().

int64_t pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::get_edge_id ( V  from,
V  to,
double &  distance 
) const
inherited
template<class G , typename T_V , typename T_E >
std::vector<int64_t> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::get_ids ( Identifiers< int64_t >  boost_ids) const
inline
template<class G , typename T_V , typename T_E >
E pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::get_min_cost_edge ( V  source,
V  destination 
)
inline

get the edge with minimum cost between two vertices

Parameters
[in]sourcevertex_descriptor of source vertex
[in]destinationvertex_descriptor of target vertex
Returns
E: The edge descriptor of the edge with minimum cost

Definition at line 147 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::graph, and pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::target().

V pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::get_V ( const T_V &  vertex)
inlineinherited

get the vertex descriptor of the vertex

When the vertex does not exist

  • creates a new vetex
Returns
V: The vertex descriptor of the vertex

Definition at line 466 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::graph, and pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::vertices_map.

Referenced by pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::add_shortcut(), and pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::get_contracted_vertices().

V pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::get_V ( int64_t  vid) const
inlineinherited

get the vertex descriptor of the vid

Call has_vertex(vid) before calling this function

Returns
V: The vertex descriptor of the vertex

Definition at line 483 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::has_vertex(), pgassert, and pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::vertices_map.

void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::graph_add_edge ( const T_E &  edge)
inherited
void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::graph_add_edge ( const T &  edge)
inherited
bool pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::has_vertex ( int64_t  vid) const
inlineinherited
degree_size_type pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::in_degree ( V v) const
inlineinherited

in degree of a vertex

  • when its undirected there is no "concept" of in degree
    • out degree is returned
  • on directed in degree of vertex is returned

Definition at line 531 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::graph, and pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::is_directed().

template<class G , typename T_V , typename T_E >
degree_size_type pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::in_degree_from_vertex ( V  vertex,
V  neighbor 
)
inline

The number of edges from neighbor to vertex.

Parameters
[in]vertexis the target of the edges
[in]neighboris the source of the edges
Returns
degree_size_type: The in-degree of vertex from neighbor

Definition at line 171 of file pgr_contractionGraph.hpp.

References pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::out_degree_to_vertex().

void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::insert_edges ( const T *  edges,
int64_t  count 
)
inlineinherited

Inserts count edges of type T into the graph.

Converts the edges to a std::vector<T> & calls the overloaded twin function.

Parameters
edges
count

Definition at line 376 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::insert_edges().

void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::insert_edges ( const std::vector< T > &  edges)
inlineinherited

Inserts count edges of type pgr_edge_t into the graph.

The set of edges should not have an illegal vertex defined

When the graph is empty calls:

  • extract_vertices and throws an exception if there are illegal vertices.

When developing:

  • if an illegal vertex is found an exception is thrown
  • That means that the set of vertices should be checked in the code that is being developed

No edge is inserted when there is an error on the vertices

Parameters
edges

Definition at line 399 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::add_vertices(), pgrouting::check_vertices(), pgrouting::extract_vertices(), pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::graph_add_edge(), pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::num_vertices(), and pgassert.

bool pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::is_source ( V  v_idx,
E  e_idx 
) const
inlineinherited
bool pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::is_target ( V  v_idx,
E  e_idx 
) const
inlineinherited
size_t pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::num_vertices ( ) const
inlineinherited
T_E& pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::operator[] ( E  e_idx)
inlineinherited
const T_E& pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::operator[] ( E  e_idx) const
inlineinherited
T_V& pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::operator[] ( V  v_idx)
inlineinherited
const T_V& pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::operator[] ( V  v_idx) const
inlineinherited
degree_size_type pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::out_degree ( int64_t  vertex_id) const
inlineinherited

get the out-degree of a vertex

Returns
0: The out degree of a vertex that its not in the graph
Parameters
[in]vertex_idoriginal vertex id

Definition at line 443 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::get_V(), pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::has_vertex(), and pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::out_degree().

degree_size_type pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::out_degree ( V v) const
inlineinherited

out degree of a vertex

regardles of undirected or directed graph

  • out degree is returned

Definition at line 542 of file pgr_base_graph.hpp.

References pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::graph.

template<class G , typename T_V , typename T_E >
degree_size_type pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::out_degree_to_vertex ( V  vertex,
V  neighbor 
)
inline
template<class G , typename T_V , typename T_E >
void pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::print_graph ( std::ostringstream &  log)
inline
void pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::restore_graph ( )
inherited

Reconnects all edges that were removed.

Member Data Documentation

graphType pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::m_gType
inherited

type (DIRECTED or UNDIRECTED)

Definition at line 308 of file pgr_base_graph.hpp.

size_t pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::m_num_vertices
inherited

local count.

Definition at line 307 of file pgr_base_graph.hpp.

Referenced by pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::print_graph().

std::deque< T_E > pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::removed_edges
inherited

Used for storing the removed_edges.

Definition at line 322 of file pgr_base_graph.hpp.

template<class G , typename T_V , typename T_E >
Identifiers<V> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::removed_vertices
template<class G , typename T_V , typename T_E >
std::vector<T_E> pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::shortcuts
id_to_V pgrouting::graph::Pgr_base_graph< G, T_V , T_E >::vertices_map
inherited

id -> graph id

Definition at line 314 of file pgr_base_graph.hpp.

Referenced by pgrouting::graph::Pgr_contractionGraph< G, T_V, T_E >::add_shortcut().


The documentation for this class was generated from the following file: