Skip to content

Commit 4f1589d

Browse files
committed
(maxFlow) Preparing functions for the new process and driver
1 parent 3a4ac13 commit 4f1589d

7 files changed

Lines changed: 59 additions & 1 deletion

File tree

include/c_common/enums.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ enum Which {
4444
PRIM = 510, PRIMDD, PRIMDFS, PRIMBFS,
4545
DFS = 520,
4646
BFS = 530,
47-
DIJKSTRADD = 540
47+
DIJKSTRADD = 540,
48+
MAXFLOW, PUSHRELABEL, BOYKOV, EDMONDSKARP
49+
4850
};
4951

5052
#endif // INCLUDE_C_COMMON_ENUMS_H_

include/cpp_common/combinations.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ get_combinations(const std::vector<II_t_rt>&);
6262
std::map<int64_t, std::set<int64_t>>
6363
get_combinations(const std::string&, ArrayType*, ArrayType*, bool, bool&);
6464

65+
std::map<int64_t, std::set<int64_t>>
66+
get_combinations(const std::string&, ArrayType*, ArrayType*, bool);
67+
6568
std::map<int64_t, std::set<int64_t>>
6669
get_combinations(const char*, ArrayType*, ArrayType*, bool);
6770

include/cpp_common/to_postgres.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3636
#include "c_types/routes_t.h"
3737
#include "c_types/path_rt.h"
3838
#include "c_types/mst_rt.h"
39+
#include "c_types/flow_t.h"
3940

4041
#include "cpp_common/path.hpp"
4142
#include "cpp_common/base_graph.hpp"
@@ -68,6 +69,11 @@ size_t get_tuples(const std::deque<pgrouting::Path>&, Path_rt*&);
6869
*/
6970
size_t get_tuples(const std::deque<pgrouting::Path>&, MST_rt*&);
7071

72+
/*
73+
* @brief get tuples for Flow_t
74+
*/
75+
size_t get_tuples(const std::vector<Flow_t>&, Flow_t*&);
76+
7177
/*
7278
* @brief get tuples for spanning tree driver
7379
*/

include/cpp_common/utilities.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3333

3434
#include "c_common/enums.h"
3535
#include "c_types/mst_rt.h"
36+
#include "c_types/flow_t.h"
3637

3738
namespace pgrouting {
3839

@@ -42,6 +43,7 @@ std::string get_name(Which, bool, bool, bool);
4243
char estimate_drivingSide(char, Which);
4344
void get_new_queries(const std::string&, const std::string&, std::string&, std::string&);
4445
std::vector<MST_rt> only_root_result(const std::set<int64_t>&);
46+
std::vector<Flow_t> only_maxFlow_result(int64_t);
4547

4648
} // namespace pgrouting
4749

src/cpp_common/combinations.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,13 @@ get_combinations(
182182
return result;
183183
}
184184

185+
std::map<int64_t , std::set<int64_t>>
186+
get_combinations(
187+
const std::string &combinations_sql,
188+
ArrayType* startsArr, ArrayType* endsArr, bool normal) {
189+
bool is_matrix = false;
190+
return get_combinations(combinations_sql, startsArr, endsArr, normal, is_matrix);
191+
}
192+
185193
} // namespace utilities
186194
} // namespace pgrouting

src/cpp_common/to_postgres.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3434
#include "c_types/routes_t.h"
3535
#include "c_types/path_rt.h"
3636
#include "c_types/mst_rt.h"
37+
#include "c_types/flow_t.h"
3738

3839
#include "cpp_common/path.hpp"
3940
#include "cpp_common/alloc.hpp"
@@ -242,6 +243,23 @@ get_tuples(
242243
return count;
243244
}
244245

246+
size_t
247+
get_tuples(
248+
const std::vector<Flow_t> &results,
249+
Flow_t* &tuples) {
250+
pgassert(!tuples);
251+
252+
auto count = results.size();
253+
if (count == 0) return 0;
254+
255+
tuples = pgr_alloc(count, tuples);
256+
257+
for (size_t i = 0; i < count; i++) {
258+
tuples[i] = results[i];
259+
}
260+
return count;
261+
}
262+
245263

246264
size_t
247265
get_tuples(

src/cpp_common/utilities.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ get_name(Which which) {
9292
case DIJKSTRADD:
9393
return "pgr_drivingDistance";
9494
break;
95+
case MAXFLOW:
96+
return "pgr_maxFlow";
97+
break;
98+
case PUSHRELABEL:
99+
return "pgr_pushRelabel";
100+
break;
101+
case BOYKOV:
102+
return "pgr_boykovKolmogorov";
103+
break;
104+
case EDMONDSKARP:
105+
return "pgr_edmondsKarp";
106+
break;
95107
default:
96108
return "unknown";
97109
break;
@@ -213,4 +225,11 @@ only_root_result(const std::set<int64_t> &vids) {
213225
return results;
214226
}
215227

228+
std::vector<Flow_t>
229+
only_maxFlow_result(int64_t maxFlow) {
230+
std::vector<Flow_t> results;
231+
results.push_back({-1, -1, -1, maxFlow, -1, 0, 0});
232+
return results;
233+
}
234+
216235
} // namespace pgrouting

0 commit comments

Comments
 (0)