PGROUTING  3.2
lineGraph_driver.h File Reference
#include <stddef.h>
#include "c_types/pgr_edge_t.h"
#include "c_types/line_graph_rt.h"
Include dependency graph for lineGraph_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void do_pgr_lineGraph (pgr_edge_t *data_edges, size_t total_edges, bool directed, Line_graph_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_lineGraph()

void do_pgr_lineGraph ( pgr_edge_t data_edges,
size_t  total_edges,
bool  directed,
Line_graph_rt **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 60 of file lineGraph_driver.cpp.

68  {
69  std::ostringstream log;
70  std::ostringstream err;
71  std::ostringstream notice;
72  try {
73  pgassert(!(*log_msg));
74  pgassert(!(*notice_msg));
75  pgassert(!(*err_msg));
76  pgassert(!(*return_tuples));
77  pgassert(*return_count == 0);
78  pgassert(total_edges != 0);
79 
80  graphType gType = directed? DIRECTED: UNDIRECTED;
81 
82  pgrouting::DirectedGraph digraph(gType);
83  digraph.insert_edges_neg(data_edges, total_edges);
84 
85  log << digraph << "\n";
89  pgrouting::Basic_edge> line(digraph);
90  std::vector< Line_graph_rt > line_graph_edges;
91  line_graph_edges = line.get_postgres_results_directed();
92  auto count = line_graph_edges.size();
93 
94  if (count == 0) {
95  (*return_tuples) = NULL;
96  (*return_count) = 0;
97  notice <<
98  "Only vertices graph";
99  } else {
100  size_t sequence = 0;
101 
103  line_graph_edges,
104  return_tuples,
105  sequence);
106  (*return_count) = sequence;
107  }
108 
109  pgassert(*err_msg == NULL);
110  *log_msg = log.str().empty()?
111  *log_msg :
112  pgr_msg(log.str().c_str());
113  *notice_msg = notice.str().empty()?
114  *notice_msg :
115  pgr_msg(notice.str().c_str());
116  } catch (AssertFailedException &except) {
117  (*return_tuples) = pgr_free(*return_tuples);
118  (*return_count) = 0;
119  err << except.what();
120  *err_msg = pgr_msg(err.str().c_str());
121  *log_msg = pgr_msg(log.str().c_str());
122  } catch (std::exception &except) {
123  (*return_tuples) = pgr_free(*return_tuples);
124  (*return_count) = 0;
125  err << except.what();
126  *err_msg = pgr_msg(err.str().c_str());
127  *log_msg = pgr_msg(log.str().c_str());
128  } catch(...) {
129  (*return_tuples) = pgr_free(*return_tuples);
130  (*return_count) = 0;
131  err << "Caught unknown exception!";
132  *err_msg = pgr_msg(err.str().c_str());
133  *log_msg = pgr_msg(log.str().c_str());
134  }
135 }

References DIRECTED, get_postgres_result(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges_neg(), pgassert, pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
AssertFailedException::what
virtual const char * what() const
Definition: pgr_assert.cpp:67
pgrouting::LinearDirectedGraph
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, Line_vertex, Basic_edge > LinearDirectedGraph
Data type to handle graph -> lineGaph transformation.
Definition: linear_directed_graph.h:55
pgrouting::Basic_edge
Definition: basic_edge.h:35
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
pgrouting::graph::Pgr_lineGraph
Definition: pgr_lineGraph.hpp:49
graphType
graphType
Definition: graph_enum.h:30
DIRECTED
@ DIRECTED
Definition: graph_enum.h:30
pgr_free
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
pgrouting::Line_vertex
Definition: line_vertex.h:45
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
get_postgres_result
void get_postgres_result(std::vector< Line_graph_rt > edge_result, Line_graph_rt **return_tuples, size_t &sequence)
Definition: lineGraph_driver.cpp:46
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139