46 int64_t *source_vertices,
size_t size_source_verticesArr,
47 int64_t *sink_vertices,
size_t size_sink_verticesArr,
51 pgr_flow_t **return_tuples,
size_t *return_count,
55 std::ostringstream log;
56 std::ostringstream notice;
57 std::ostringstream err;
67 pgassert((source_vertices && sink_vertices) || combinations);
68 pgassert((size_source_verticesArr && size_sink_verticesArr) || total_combinations);
70 std::vector<pgr_edge_t> edges(data_edges, data_edges + total_edges);
71 std::set<int64_t> sources(
72 source_vertices, source_vertices + size_source_verticesArr);
73 std::set<int64_t> targets(
74 sink_vertices, sink_vertices + size_sink_verticesArr);
75 std::vector< pgr_combination_t > combinations_vector(
76 combinations, combinations + total_combinations);
78 if (!combinations_vector.empty()) {
83 sources.insert(comb.source);
84 targets.insert(comb.target);
88 std::set<int64_t> vertices(sources);
89 vertices.insert(targets.begin(), targets.end());
92 != (sources.size() + targets.size())) {
93 *err_msg =
pgr_msg(
"A source found as sink");
101 edges, sources, targets, algorithm);
105 if (algorithm == 1) {
107 }
else if (algorithm == 3) {
109 }
else if (algorithm == 2) {
112 log <<
"Unspecified algorithm!\n";
113 *err_msg =
pgr_msg(log.str().c_str());
114 (*return_tuples) = NULL;
120 std::vector<pgr_flow_t> flow_edges;
127 edge.flow = max_flow;
128 edge.residual_capacity = -1;
129 flow_edges.push_back(
edge);
133 (*return_tuples) =
pgr_alloc(flow_edges.size(), (*return_tuples));
134 for (
size_t i = 0; i < flow_edges.size(); ++i) {
135 (*return_tuples)[i] = flow_edges[i];
137 *return_count = flow_edges.size();
140 *log_msg = log.str().empty()?
143 *notice_msg = notice.str().empty()?
147 (*return_tuples) =
pgr_free(*return_tuples);
149 err << except.
what();
150 *err_msg =
pgr_msg(err.str().c_str());
151 *log_msg =
pgr_msg(log.str().c_str());
152 }
catch (std::exception &except) {
153 (*return_tuples) =
pgr_free(*return_tuples);
155 err << except.what();
156 *err_msg =
pgr_msg(err.str().c_str());
157 *log_msg =
pgr_msg(log.str().c_str());
159 (*return_tuples) =
pgr_free(*return_tuples);
161 err <<
"Caught unknown exception!";
162 *err_msg =
pgr_msg(err.str().c_str());
163 *log_msg =
pgr_msg(log.str().c_str());