51 post_process(std::deque<Path> &paths,
bool only_cost,
bool normal,
size_t n_goals,
bool global) {
52 paths.erase(std::remove_if(paths.begin(), paths.end(),
57 using difference_type = std::deque<double>::difference_type;
60 for (
auto &path : paths) path.reverse();
64 for (
auto &p : paths) {
69 if (n_goals != (std::numeric_limits<size_t>::max)()) {
70 std::sort(paths.begin(), paths.end(),
71 [](
const Path &e1,
const Path &e2)->bool {
72 return e1.end_id() < e2.end_id();
74 std::stable_sort(paths.begin(), paths.end(),
75 [](
const Path &e1,
const Path &e2)->bool {
76 return e1.start_id() < e2.start_id();
78 std::stable_sort(paths.begin(), paths.end(),
79 [](
const Path &e1,
const Path &e2)->bool {
80 return e1.tot_cost() < e2.tot_cost();
82 if (global && n_goals < paths.size()) {
83 paths.erase(paths.begin() +
static_cast<difference_type
>(n_goals), paths.end());
86 std::sort(paths.begin(), paths.end(),
87 [](
const Path &e1,
const Path &e2)->bool {
88 return e1.end_id() < e2.end_id();
90 std::stable_sort(paths.begin(), paths.end(),
91 [](
const Path &e1,
const Path &e2)->bool {
92 return e1.start_id() < e2.start_id();
102 std::vector < int64_t > sources,
103 std::vector < int64_t > targets,
108 std::sort(sources.begin(), sources.end());
110 std::unique(sources.begin(), sources.end()),
113 std::sort(targets.begin(), targets.end());
115 std::unique(targets.begin(), targets.end()),
124 post_process(paths, only_cost, normal, n_goals, global);
134 std::vector < pgr_combination_t > &combinations,
145 post_process(paths, only_cost, normal, n_goals, global);
161 int64_t *start_vidsArr,
162 size_t size_start_vidsArr,
163 int64_t *end_vidsArr,
164 size_t size_end_vidsArr,
172 size_t *return_count,
176 std::ostringstream log;
177 std::ostringstream err;
178 std::ostringstream notice;
191 start_vertices(start_vidsArr, start_vidsArr + size_start_vidsArr);
192 std::vector< int64_t >
193 end_vertices(end_vidsArr, end_vidsArr + size_end_vidsArr);
195 size_t n = n_goals <= 0? (std::numeric_limits<size_t>::max)() :
static_cast<size_t>(n_goals);
197 std::deque< Path >paths;
203 start_vertices, end_vertices,
204 only_cost, normal, n, global);
210 start_vertices, end_vertices,
211 only_cost, normal, n, global);
218 (*return_tuples) = NULL;
222 *log_msg =
pgr_msg(notice.str().c_str());
226 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
229 *log_msg = log.str().empty()?
232 *notice_msg = notice.str().empty()?
236 (*return_tuples) =
pgr_free(*return_tuples);
238 err << except.
what();
239 *err_msg =
pgr_msg(err.str().c_str());
240 *log_msg =
pgr_msg(log.str().c_str());
241 }
catch (std::exception &except) {
242 (*return_tuples) =
pgr_free(*return_tuples);
244 err << except.what();
245 *err_msg =
pgr_msg(err.str().c_str());
246 *log_msg =
pgr_msg(log.str().c_str());
248 (*return_tuples) =
pgr_free(*return_tuples);
250 err <<
"Caught unknown exception!";
251 *err_msg =
pgr_msg(err.str().c_str());
252 *log_msg =
pgr_msg(log.str().c_str());
266 size_t total_combinations,
274 size_t *return_count,
278 std::ostringstream log;
279 std::ostringstream err;
280 std::ostringstream notice;
294 std::vector<pgr_combination_t>
295 combinations_vector(combinations, combinations + total_combinations);
297 size_t n = n_goals <= 0? (std::numeric_limits<size_t>::max)() :
static_cast<size_t>(n_goals);
299 std::deque< Path >paths;
306 only_cost, normal, n, global);
313 only_cost, normal, n, global);
315 combinations_vector.clear();
320 (*return_tuples) = NULL;
322 notice <<
"No paths found";
323 *log_msg =
pgr_msg(notice.str().c_str());
327 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
330 *log_msg = log.str().empty()?
333 *notice_msg = notice.str().empty()?
337 (*return_tuples) =
pgr_free(*return_tuples);
339 err << except.
what();
340 *err_msg =
pgr_msg(err.str().c_str());
341 *log_msg =
pgr_msg(log.str().c_str());
342 }
catch (std::exception &except) {
343 (*return_tuples) =
pgr_free(*return_tuples);
345 err << except.what();
346 *err_msg =
pgr_msg(err.str().c_str());
347 *log_msg =
pgr_msg(log.str().c_str());
349 (*return_tuples) =
pgr_free(*return_tuples);
351 err <<
"Caught unknown exception!";
352 *err_msg =
pgr_msg(err.str().c_str());
353 *log_msg =
pgr_msg(log.str().c_str());