59 std::vector < int64_t > sources,
60 std::vector < int64_t > targets,
67 log <<
"entering static function\n";
68 std::sort(sources.begin(), sources.end());
70 std::unique(sources.begin(), sources.end()),
73 std::sort(targets.begin(), targets.end());
75 std::unique(targets.begin(), targets.end()),
80 std::deque<Path> paths;
81 for (
const auto source : sources) {
82 for (
const auto target : targets) {
83 if (source == target) {
84 paths.push_back(
Path(source, target));
88 if (!graph.has_vertex(source)
89 || !graph.has_vertex(target)) {
90 paths.push_back(
Path(source, target));
96 graph.get_V(source), graph.get_V(target),
97 heuristic, factor, epsilon, only_cost));
100 log << fn_bdAstar.
log();
110 int64_t *start_vidsArr,
111 size_t size_start_vidsArr,
112 int64_t *end_vidsArr,
113 size_t size_end_vidsArr,
123 size_t *return_count,
128 std::ostringstream log;
129 std::ostringstream err;
130 std::ostringstream notice;
140 log <<
"Inserting vertices into a c++ vector structure";
142 start_vertices(start_vidsArr, start_vidsArr + size_start_vidsArr);
143 std::vector< int64_t >
144 end_vertices(end_vidsArr, end_vidsArr + size_end_vidsArr);
148 std::deque<Path> paths;
149 log <<
"starting process\n";
151 log <<
"Working with directed Graph\n";
166 log <<
"Working with Undirected Graph\n";
187 (*return_tuples) = NULL;
191 *log_msg =
pgr_msg(notice.str().c_str());
195 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
196 log <<
"\nConverting a set of paths into the tuples";
201 auto count = path.size();
204 (*return_tuples) = NULL;
207 "No paths found between start_vid and end_vid vertices";
209 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
211 path.generate_postgres_data(return_tuples, sequence);
212 (*return_count) = sequence;
217 *log_msg = log.str().empty()?
220 *notice_msg = notice.str().empty()?
224 if (*return_tuples) free(*return_tuples);
226 err << except.
what();
227 *err_msg =
pgr_msg(err.str().c_str());
228 *log_msg =
pgr_msg(log.str().c_str());
229 }
catch (std::exception& except) {
230 if (*return_tuples) free(*return_tuples);
232 err << except.what();
233 *err_msg =
pgr_msg(err.str().c_str());
234 *log_msg =
pgr_msg(log.str().c_str());
236 if (*return_tuples) free(*return_tuples);
238 err <<
"Caught unknown exception!";
239 *err_msg =
pgr_msg(err.str().c_str());
240 *log_msg =
pgr_msg(log.str().c_str());
Extends std::exception and is the exception that we throw if an assert fails.
void do_pgr_bdAstar(Pgr_edge_xy_t *edges, size_t total_edges, int64_t *start_vidsArr, size_t size_start_vidsArr, int64_t *end_vidsArr, size_t size_end_vidsArr, bool directed, int heuristic, double factor, double epsilon, bool only_cost, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
size_t collapse_paths(General_path_element_t **ret_path, const std::deque< Path > &paths)
graph::Pgr_base_graph< BG, XY_vertex, Basic_edge > G
static std::deque< Path > pgr_bdAstar(G &graph, std::vector< int64_t > sources, std::vector< int64_t > targets, int heuristic, double factor, double epsilon, std::ostream &log, bool only_cost)
#define pgassert(expr)
Uses the standard assert syntax.
std::vector< Basic_vertex > extract_vertices(std::vector< Basic_vertex > vertices, const std::vector< pgr_edge_t > data_edges)
char * pgr_msg(const std::string &msg)
size_t count_tuples(const std::deque< Path > &paths)
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Path pgr_bdAstar(V start_vertex, V end_vertex, int heuristic, double factor, double epsilon, bool only_cost)
virtual const char * what() const
void insert_edges(const T *edges, size_t count)
Inserts count edges of type T into the graph.