forked from pgRouting/GSoC-pgRouting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GSoC 2023: Aniket Agarwal Week 2 (pgRouting#295)
* added one-to-many overload and try to run pgtap on ksp * removed white spaces at the end of the lines * update function's developer * added overloads * fixing the errors * fixing more errors * added function's developer and updates in .hpp * fixed error of algorithm * fix the start_id and route_id problem * changes in ksp.sql to pass tests * fixing linting * fixing linter * added name in contributor list and added namspace comment
- Loading branch information
1 parent
2e50d9d
commit 953978f
Showing
10 changed files
with
435 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ build | |
fix_typos | ||
code_linter | ||
src/version/version.h | ||
|
||
run.sh | ||
taptest.sh | ||
.DS_Store | ||
.vagrant | ||
.directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ File: ksp_driver.h | |
Copyright (c) 2015 Celia Virginia Vergara Castillo | ||
Mail: [email protected] | ||
Copyright (c) 2023 Aniket Agarwal | ||
Mail: [email protected] | ||
------ | ||
This program is free software; you can redistribute it and/or modify | ||
|
@@ -32,11 +35,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
# include <cstddef> | ||
using Edge_t = struct Edge_t; | ||
using Path_rt = struct Path_rt; | ||
using II_t_rt = struct II_t_rt; | ||
#else | ||
# include <stddef.h> | ||
# include <stdint.h> | ||
typedef struct Edge_t Edge_t; | ||
typedef struct Path_rt Path_rt; | ||
typedef struct II_t_rt II_t_rt; | ||
#endif | ||
|
||
|
||
|
@@ -47,13 +52,23 @@ extern "C" { | |
void do_pgr_ksp( | ||
Edge_t *data_edges, | ||
size_t total_edges, | ||
int64_t start_vid, | ||
int64_t end_vid, | ||
|
||
II_t_rt *combinations, | ||
size_t total_combinations, | ||
|
||
int64_t *start_vids, | ||
size_t size_start_vids, | ||
int64_t *end_vids, | ||
size_t size_end_vids, | ||
|
||
size_t K, | ||
|
||
bool directed, | ||
bool heap_paths, | ||
|
||
Path_rt **return_tuples, | ||
size_t *return_count, | ||
|
||
char ** log_msg, | ||
char ** notice_msg, | ||
char ** err_msg); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ File: pgr_ksp.hpp | |
Copyright (c) 2015 Celia Virginia Vergara Castillo | ||
Mail: [email protected] | ||
Copyright (c) 2023 Aniket Agarwal | ||
Mail: [email protected] | ||
------ | ||
This program is free software; you can redistribute it and/or modify | ||
|
@@ -26,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
#define INCLUDE_YEN_PGR_KSP_HPP_ | ||
#pragma once | ||
|
||
|
||
#include <map> | ||
#include <sstream> | ||
#include <deque> | ||
#include <vector> | ||
|
@@ -236,6 +239,40 @@ class Pgr_ksp : public Pgr_messages { | |
|
||
|
||
} // namespace yen | ||
|
||
/* | ||
* Added the namespace algorithm to calculate combinations | ||
*/ | ||
namespace algorithms { | ||
|
||
template <class G> | ||
std::deque<Path> ksp( | ||
G &graph, | ||
const std::map<int64_t, std::set<int64_t>> &combinations, | ||
size_t k, | ||
bool heap_paths) { | ||
std::deque<Path> paths; | ||
pgrouting::yen::Pgr_ksp<G> fn_yen; | ||
|
||
for (const auto &c : combinations) { | ||
if (!graph.has_vertex(c.first)) | ||
continue; | ||
|
||
for (const auto &destination : c.second) { | ||
if (!graph.has_vertex(destination)) | ||
continue; | ||
|
||
fn_yen.clear(); | ||
auto result_path = fn_yen.Yen(graph, c.first, destination, k, heap_paths); | ||
paths.insert(paths.end(), result_path.begin(), result_path.end()); | ||
} | ||
} | ||
|
||
return paths; | ||
} | ||
|
||
} // namespace algorithms | ||
|
||
} // namespace pgrouting | ||
|
||
#endif // INCLUDE_YEN_PGR_KSP_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ File: _ksp.sql | |
Copyright (c) 2015 Celia Virginia Vergara Castillo | ||
[email protected] | ||
Copyright (c) 2023 Aniket Agarwal | ||
[email protected] | ||
------ | ||
This program is free software; you can redistribute it and/or modify | ||
|
@@ -28,10 +31,57 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
--------------- | ||
|
||
--v2.6 | ||
-- CREATE FUNCTION _pgr_ksp( | ||
-- edges_sql TEXT, | ||
-- start_vid INTEGER, | ||
-- end_vid INTEGER, | ||
-- k INTEGER, | ||
|
||
-- directed BOOLEAN, | ||
-- heap_paths BOOLEAN, | ||
|
||
-- OUT seq INTEGER, | ||
-- OUT path_id INTEGER, | ||
-- OUT path_seq INTEGER, | ||
-- OUT start_vid BIGINT, | ||
-- OUT end_vid BIGINT, | ||
-- OUT node BIGINT, | ||
-- OUT edge BIGINT, | ||
-- OUT cost FLOAT, | ||
-- OUT agg_cost FLOAT) | ||
-- RETURNS SETOF RECORD AS | ||
-- 'MODULE_PATHNAME' | ||
-- LANGUAGE C VOLATILE STRICT; | ||
|
||
|
||
--v3.6 | ||
CREATE FUNCTION _pgr_ksp( | ||
edges_sql TEXT, | ||
start_vids ANYARRAY, | ||
end_vids ANYARRAY, | ||
k INTEGER, | ||
|
||
directed BOOLEAN, | ||
heap_paths BOOLEAN, | ||
|
||
OUT seq INTEGER, | ||
OUT path_id INTEGER, | ||
OUT path_seq INTEGER, | ||
OUT start_vid BIGINT, | ||
OUT end_vid BIGINT, | ||
OUT node BIGINT, | ||
OUT edge BIGINT, | ||
OUT cost FLOAT, | ||
OUT agg_cost FLOAT) | ||
RETURNS SETOF RECORD AS | ||
'MODULE_PATHNAME' | ||
LANGUAGE C VOLATILE STRICT; | ||
|
||
--v3.6 | ||
CREATE FUNCTION _pgr_ksp( | ||
edges_sql TEXT, | ||
start_vid BIGINT, | ||
end_vid BIGINT, | ||
combinations TEXT, | ||
|
||
k INTEGER, | ||
|
||
directed BOOLEAN, | ||
|
@@ -40,6 +90,8 @@ CREATE FUNCTION _pgr_ksp( | |
OUT seq INTEGER, | ||
OUT path_id INTEGER, | ||
OUT path_seq INTEGER, | ||
OUT start_vid BIGINT, | ||
OUT end_vid BIGINT, | ||
OUT node BIGINT, | ||
OUT edge BIGINT, | ||
OUT cost FLOAT, | ||
|
@@ -50,5 +102,8 @@ LANGUAGE C VOLATILE STRICT; | |
|
||
-- COMMENTS | ||
|
||
COMMENT ON FUNCTION _pgr_ksp(TEXT, BIGINT, BIGINT, INTEGER, BOOLEAN, BOOLEAN) | ||
COMMENT ON FUNCTION _pgr_ksp(TEXT, ANYARRAY, ANYARRAY, INTEGER, BOOLEAN, BOOLEAN) | ||
IS 'pgRouting internal function'; | ||
|
||
COMMENT ON FUNCTION _pgr_ksp(TEXT, TEXT, INTEGER, BOOLEAN, BOOLEAN) | ||
IS 'pgRouting internal function'; |
Oops, something went wrong.