48 std::vector<int64_t> sources,
49 std::vector<int64_t> targets,
55 std::sort(sources.begin(), sources.end());
57 std::unique(sources.begin(), sources.end()),
60 std::sort(targets.begin(), targets.end());
62 std::unique(targets.begin(), targets.end()),
66 auto paths = fn_astar.
astar(graph, sources, targets,
67 heuristic, factor, epsilon, only_cost);
70 for (
auto &path : paths) {
86 int64_t *start_vidsArr,
size_t size_start_vidsArr,
87 int64_t *end_vidsArr,
size_t size_end_vidsArr,
99 std::ostringstream log;
100 std::ostringstream notice;
101 std::ostringstream err;
110 log <<
"Inserting target vertices into a c++ vector structure\n";
111 std::vector< int64_t > end_vids(
113 end_vidsArr + size_end_vidsArr);
114 std::vector< int64_t > start_vids(
116 start_vidsArr + size_start_vidsArr);
120 std::deque< Path >paths;
122 log <<
"Working with directed Graph\n";
127 paths =
pgr_astar(digraph, start_vids, end_vids,
128 heuristic, factor, epsilon, only_cost, normal);
130 log <<
"Working with Undirected Graph\n";
135 paths =
pgr_astar(undigraph, start_vids, end_vids,
136 heuristic, factor, epsilon, only_cost, normal);
144 (*return_tuples) = NULL;
148 *log_msg =
pgr_msg(notice.str().c_str());
152 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
153 log <<
"Converting a set of paths into the tuples\n";
156 *log_msg = log.str().empty()?
159 *notice_msg = notice.str().empty()?
163 (*return_tuples) =
pgr_free(*return_tuples);
165 err << except.
what();
166 *err_msg =
pgr_msg(err.str().c_str());
167 *log_msg =
pgr_msg(log.str().c_str());
168 }
catch (std::exception &except) {
169 (*return_tuples) =
pgr_free(*return_tuples);
171 err << except.what();
172 *err_msg =
pgr_msg(err.str().c_str());
173 *log_msg =
pgr_msg(log.str().c_str());
175 (*return_tuples) =
pgr_free(*return_tuples);
177 err <<
"Caught unknown exception!";
178 *err_msg =
pgr_msg(err.str().c_str());
179 *log_msg =
pgr_msg(log.str().c_str());
Extends std::exception and is the exception that we throw if an assert fails.
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
#define pgassert(expr)
Uses the standard assert syntax.
Path astar(G &graph, int64_t start_vertex, int64_t end_vertex, int heuristic, double factor, double epsilon, bool only_cost)
one to one astar 1 to 1
std::deque< Path > pgr_astar(G &graph, std::vector< int64_t > sources, std::vector< int64_t > targets, int heuristic, double factor, double epsilon, bool only_cost, bool normal)
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
virtual const char * what() const
void do_pgr_astarManyToMany(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, bool normal, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
void insert_edges(const T *edges, size_t count)
Inserts count edges of type T into the graph.