PGROUTING  3.2
edwardMoore_driver.h File Reference
#include <stddef.h>
#include "c_types/pgr_edge_t.h"
#include "c_types/pgr_combination_t.h"
#include "c_types/general_path_element_t.h"
Include dependency graph for edwardMoore_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_edwardMoore (pgr_edge_t *data_edges, size_t total_tuples, pgr_combination_t *combinations, size_t total_combinations, int64_t *start_vidsArr, size_t size_start_vidsArr, int64_t *end_vidsArr, size_t size_end_vidsArr, bool directed, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_edwardMoore()

void do_pgr_edwardMoore ( pgr_edge_t data_edges,
size_t  total_tuples,
pgr_combination_t combinations,
size_t  total_combinations,
int64_t *  start_vidsArr,
size_t  size_start_vidsArr,
int64_t *  end_vidsArr,
size_t  size_end_vidsArr,
bool  directed,
General_path_element_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 82 of file edwardMoore_driver.cpp.

97  {
98  std::ostringstream log;
99  std::ostringstream err;
100  std::ostringstream notice;
101 
102  try {
103  pgassert(total_edges != 0);
104  pgassert(!(*log_msg));
105  pgassert(!(*notice_msg));
106  pgassert(!(*err_msg));
107  pgassert(!(*return_tuples));
108  pgassert(*return_count == 0);
109  pgassert(data_edges);
110  pgassert((start_vidsArr && end_vidsArr) || combinations);
111  pgassert((size_start_vidsArr && size_end_vidsArr) || total_combinations);
112 
113  graphType gType = directed? DIRECTED: UNDIRECTED;
114 
115  log << "Inserting vertices into a c++ vector structure";
116  std::vector<int64_t>
117  start_vertices(start_vidsArr, start_vidsArr + size_start_vidsArr);
118  std::vector< int64_t >
119  end_vertices(end_vidsArr, end_vidsArr + size_end_vidsArr);
120  std::vector< pgr_combination_t >
121  combinations_vector(combinations, combinations + total_combinations);
122 
123 
124  std::deque< Path >paths;
125  if (directed) {
126  log << "\nWorking with directed Graph";
127  pgrouting::DirectedGraph digraph(gType);
128  digraph.insert_edges(data_edges, total_edges);
129  paths = pgr_edwardMoore(
130  digraph,
131  combinations_vector,
132  start_vertices,
133  end_vertices);
134  } else {
135  log << "\nWorking with Undirected Graph";
136  pgrouting::UndirectedGraph undigraph(gType);
137  undigraph.insert_edges(data_edges, total_edges);
138 
139  paths = pgr_edwardMoore(
140  undigraph,
141  combinations_vector,
142  start_vertices,
143  end_vertices);
144  }
145 
146  size_t count(0);
147  count = count_tuples(paths);
148 
149  if (count == 0) {
150  (*return_tuples) = NULL;
151  (*return_count) = 0;
152  notice <<
153  "No paths found";
154  *log_msg = pgr_msg(notice.str().c_str());
155  return;
156  }
157 
158  (*return_tuples) = pgr_alloc(count, (*return_tuples));
159  log << "\nConverting a set of paths into the tuples";
160  (*return_count) = (collapse_paths(return_tuples, paths));
161 
162  *log_msg = log.str().empty()?
163  *log_msg :
164  pgr_msg(log.str().c_str());
165  *notice_msg = notice.str().empty()?
166  *notice_msg :
167  pgr_msg(notice.str().c_str());
168  } catch (AssertFailedException &except) {
169  (*return_tuples) = pgr_free(*return_tuples);
170  (*return_count) = 0;
171  err << except.what();
172  *err_msg = pgr_msg(err.str().c_str());
173  *log_msg = pgr_msg(log.str().c_str());
174  } catch (std::exception &except) {
175  (*return_tuples) = pgr_free(*return_tuples);
176  (*return_count) = 0;
177  err << except.what();
178  *err_msg = pgr_msg(err.str().c_str());
179  *log_msg = pgr_msg(log.str().c_str());
180  } catch(...) {
181  (*return_tuples) = pgr_free(*return_tuples);
182  (*return_count) = 0;
183  err << "Caught unknown exception!";
184  *err_msg = pgr_msg(err.str().c_str());
185  *log_msg = pgr_msg(log.str().c_str());
186  }
187 }

References collapse_paths(), count_tuples(), DIRECTED, pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_alloc(), pgr_edwardMoore(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
count_tuples
size_t count_tuples(const std::deque< Path > &paths)
Definition: basePath_SSEC.cpp:387
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
collapse_paths
size_t collapse_paths(General_path_element_t **ret_path, const std::deque< Path > &paths)
Definition: basePath_SSEC.cpp:310
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgr_edwardMoore
std::deque< Path > pgr_edwardMoore(G &graph, std::vector< pgr_combination_t > &combinations, std::vector< int64_t > sources, std::vector< int64_t > targets)
Definition: edwardMoore_driver.cpp:58
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
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::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139