PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lineGraph_driver.h File Reference
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

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 58 of file lineGraph_driver.cpp.

References DIRECTED, get_postgres_result(), pgrouting::graph::Pgr_lineGraph< G, T_V, T_E >::get_postgres_results_directed(), pgrouting::graph::Pgr_lineGraph< G, T_V, T_E >::get_postgres_results_undirected(), pgr_edge_t::id, pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::insert_edges(), pgrouting::graph::Pgr_lineGraph< G, T_V, T_E >::insert_vertices(), pgrouting::graph::Pgr_lineGraph< G, T_V, T_E >::log, pgrouting::graph::Pgr_base_graph< G, Vertex, Edge >::m_num_vertices, pgassert, pgr_free(), pgr_msg(), pgrouting::graph::Pgr_lineGraph< G, T_V, T_E >::transform(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

66  {
67  std::ostringstream log;
68  std::ostringstream err;
69  std::ostringstream notice;
70  try {
71  pgassert(!(*log_msg));
72  pgassert(!(*notice_msg));
73  pgassert(!(*err_msg));
74  pgassert(!(*return_tuples));
75  pgassert(*return_count == 0);
76  pgassert(total_edges != 0);
77 
78  std::vector< Line_graph_rt > results;
79  graphType gType = directed?DIRECTED:UNDIRECTED;
80 
81  pgrouting::DirectedGraph digraph(gType);
82  digraph.insert_edges(data_edges, total_edges);
83  if (!directed) {
84  for (size_t ind = 0; ind < total_edges; ind++) {
85  std::swap(data_edges[ind].source, data_edges[ind].target);
86  data_edges[ind].id *= -1;
87  }
88 
89  digraph.insert_edges(data_edges, total_edges);
90 
91  for (size_t ind = 0;ind < total_edges; ind++) {
92  std::swap(data_edges[ind].source, data_edges[ind].target);
93  data_edges[ind].id *= -1;
94  }
95  }
96 
97  digraph.m_num_vertices = 1000;
98  log << digraph << "\n";
99 
100  pgrouting::LinearDirectedGraph line(gType);
101  line.insert_vertices(data_edges, total_edges);
102  line.transform(digraph);
103 
104  std::vector< Line_graph_rt > line_graph_edges;
105  if (directed) {
106  line_graph_edges = line.get_postgres_results_directed();
107  } else {
108  line_graph_edges = line.get_postgres_results_undirected();
109  }
110 
111  auto count = line_graph_edges.size();
112 
113  if (count == 0) {
114  (*return_tuples) = NULL;
115  (*return_count) = 0;
116  notice <<
117  "No paths found between start_vid and end_vid vertices";
118  } else {
119  size_t sequence = 0;
120 
122  line_graph_edges,
123  return_tuples,
124  sequence
125  );
126  (*return_count) = sequence;
127  }
128  log << line.log.str().c_str() << "\n\n\n";
129  log << line << "\n";
130 
131  pgassert(*err_msg == NULL);
132  *log_msg = log.str().empty()?
133  *log_msg :
134  pgr_msg(log.str().c_str());
135  *notice_msg = notice.str().empty()?
136  *notice_msg :
137  pgr_msg(notice.str().c_str());
138  } catch (AssertFailedException &except) {
139  (*return_tuples) = pgr_free(*return_tuples);
140  (*return_count) = 0;
141  err << except.what();
142  *err_msg = pgr_msg(err.str().c_str());
143  *log_msg = pgr_msg(log.str().c_str());
144  } catch (std::exception &except) {
145  (*return_tuples) = pgr_free(*return_tuples);
146  (*return_count) = 0;
147  err << except.what();
148  *err_msg = pgr_msg(err.str().c_str());
149  *log_msg = pgr_msg(log.str().c_str());
150  } catch(...) {
151  (*return_tuples) = pgr_free(*return_tuples);
152  (*return_count) = 0;
153  err << "Caught unknown exception!";
154  *err_msg = pgr_msg(err.str().c_str());
155  *log_msg = pgr_msg(log.str().c_str());
156  }
157 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:75
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
int64_t id
Definition: pgr_edge_t.h:59
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:29
virtual const char * what() const
Definition: pgr_assert.cpp:53
void get_postgres_result(std::vector< Line_graph_rt > edge_result, Line_graph_rt **return_tuples, size_t &sequence)
graphType
Definition: graph_enum.h:30

Here is the call graph for this function:

Here is the caller graph for this function: