44 std::vector<General_path_element_t>
46 std::vector<pgr_edge_t> edges,
50 std::set<int64_t> set_source_vertices;
51 std::set<int64_t> set_sink_vertices;
52 set_source_vertices.insert(source);
53 set_sink_vertices.insert(target);
57 set_sink_vertices, directed);
62 return G.edge_disjoint_paths();
70 size_t total_combinations,
72 size_t size_source_verticesArr,
74 size_t size_sink_verticesArr,
81 std::ostringstream log;
82 std::ostringstream notice;
83 std::ostringstream err;
92 pgassert((sources && sinks) || combinations);
93 pgassert((size_source_verticesArr && size_sink_verticesArr) || total_combinations);
95 std::set<int64_t> set_source_vertices(
96 sources, sources + size_source_verticesArr);
97 std::set<int64_t> set_sink_vertices(
98 sinks, sinks + size_sink_verticesArr);
99 std::vector< pgr_combination_t > combinations_vector(
100 combinations, combinations + total_combinations);
101 std::vector<pgr_edge_t> edges(
102 data_edges, data_edges + total_edges);
104 if (!combinations_vector.empty()) {
105 pgassert(set_source_vertices.empty());
106 pgassert(set_sink_vertices.empty());
109 set_source_vertices.insert(comb.source);
110 set_sink_vertices.insert(comb.target);
115 std::vector<General_path_element_t> paths;
116 for (
const auto &s : set_source_vertices) {
117 for (
const auto &t : set_sink_vertices) {
123 paths.insert(paths.end(), path.begin(), path.end());
128 *return_tuples =
nullptr;
136 for (
auto &r : paths) {
143 auto found = paths.size();
144 for (
const auto &e : edges) {
145 for (
auto &r : paths) {
146 if (r.edge == e.id) {
147 r.cost = (r.node == e.source) ?
148 e.cost : e.reverse_cost;
152 if (found == 0)
break;
158 auto prev = paths[0];
159 for (
auto &r : paths) {
163 r.agg_cost = prev.agg_cost + prev.cost;
172 for (
auto &r : paths) {
173 r.start_id = path_id;
174 if (r.edge == -1) ++path_id;
178 (*return_tuples) =
pgr_alloc(paths.size(), (*return_tuples));
179 for (
size_t i = 0; i < paths.size(); ++i) {
180 (*return_tuples)[i] = paths[i];
182 *return_count = paths.size();
185 *log_msg = log.str().empty()?
188 *notice_msg = notice.str().empty()?
192 (*return_tuples) =
pgr_free(*return_tuples);
194 err << except.
what();
195 *err_msg =
pgr_msg(err.str().c_str());
196 *log_msg =
pgr_msg(log.str().c_str());
197 }
catch (std::exception &except) {
198 (*return_tuples) =
pgr_free(*return_tuples);
200 err << except.what();
201 *err_msg =
pgr_msg(err.str().c_str());
202 *log_msg =
pgr_msg(log.str().c_str());
204 (*return_tuples) =
pgr_free(*return_tuples);
206 err <<
"Caught unknown exception!";
207 *err_msg =
pgr_msg(err.str().c_str());
208 *log_msg =
pgr_msg(log.str().c_str());