Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read postgresql data on C++ #2607

Merged
merged 71 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
ca7abd2
postgres_connection.h char* -> const char*
cvvergara Jan 22, 2024
5766431
:heavy-plus-sign: trsp_pgfetch copy of pgdata_fetchers
cvvergara Jan 22, 2024
75ca153
:heavy-plus-sign: undefPostgresDefine.hpp needed for undef postgres d…
cvvergara Jan 22, 2024
0ac40ef
:heavy-plus-sign: trsp_pgget copy of pgdata_getters
cvvergara Jan 22, 2024
65c84de
c_common pgdata_getters.h -> cpp_common/pgdata_getters.hpp
cvvergara Jan 22, 2024
29264ef
pgdata_getters to be used from C++
cvvergara Jan 22, 2024
8e5930a
pgdata_fetchers to return a (C++) structure
cvvergara Jan 22, 2024
bbe3710
get_check_data arrays stored them in C++ containers
cvvergara Jan 22, 2024
76a37f4
cpp_common headers minor changes
cvvergara Jan 22, 2024
feefe5a
get_data: New template function to read data from C++
cvvergara Jan 22, 2024
442d1e3
interruption.h -> interruption.hpp should be a C++ header file
cvvergara Jan 22, 2024
9fcd6b2
(C++) Using interruption.hpp
cvvergara Jan 22, 2024
22b0fdb
interruption.hpp undef posgres defines
cvvergara Jan 22, 2024
bf8ec68
pgr_base_graph.hpp
cvvergara Jan 22, 2024
7f78c9f
combinations.h -> combinations.hpp should be A c++ header
cvvergara Jan 22, 2024
8ba1f41
Combinations new functions to create from container
cvvergara Jan 22, 2024
7571453
Using combinations.hpp
cvvergara Jan 22, 2024
4eefcab
On C code using trsp_pgget
cvvergara Jan 22, 2024
a6118e2
[tools] pgtap script to not show NOTICE
cvvergara Jan 24, 2024
775ca21
[allpairs] Reading data on C++ code part1
cvvergara Jan 22, 2024
cb194b4
[allpairs] Reading data on C++ code part2 (removing unused code)
cvvergara Jan 22, 2024
1e9f2a3
[alpha_shape] Reading data on C++ code
cvvergara Jan 22, 2024
a5d36f8
[alpha_shape] do_ -> pgr_do_
cvvergara Jan 24, 2024
bf74f30
[astar] Reading data on C++ code
cvvergara Jan 22, 2024
ae00930
[bdAstar] Reading data on C++ code
cvvergara Jan 22, 2024
3c084eb
[bdDijkstra] Reading data on C++ code
cvvergara Jan 23, 2024
9eedf0a
[bellman_ford] Reading data on C++ code
cvvergara Jan 23, 2024
f368453
[breadthFirstSearch] Reading data on C++ code
cvvergara Jan 23, 2024
b0035f5
[chinese] Reading data on C++ code
cvvergara Jan 23, 2024
a53a2c8
[circuits] hawickcircuits_driver.h -> hawickCircuits_driver.h
cvvergara Jan 23, 2024
e03f0c5
[circuits] Reading data on C++ code
cvvergara Jan 23, 2024
08eef7c
[coloring] Reading data on C++ code
cvvergara Jan 23, 2024
ff1c536
[components] Reading data on C++ code
cvvergara Jan 24, 2024
5e660f8
[contraction] Reading data on C++ code
cvvergara Jan 24, 2024
b183403
[dagShortestPath] Reading data on C++ code
cvvergara Jan 24, 2024
cdb2c64
[dijkstra] Reading data on C++ code
cvvergara Jan 24, 2024
ca97274
[dominator] Reading data on C++ code
cvvergara Jan 24, 2024
056d6c5
[driving_distance] Reading data on C++ code
cvvergara Jan 24, 2024
ac1063b
[ksp] Reading data on C++ code
cvvergara Jan 24, 2024
2421e93
[linegraph] Reading data on C++ code
cvvergara Jan 24, 2024
d93e57f
[max_flow] Reading data on C++ code
cvvergara Jan 24, 2024
90be540
[mincut] Reading data on C++ code
cvvergara Jan 24, 2024
ccc52a6
[ordering] Reading data on C++ code
cvvergara Jan 24, 2024
b96119e
[pickDeliver] Reading data on C++ code
cvvergara Jan 24, 2024
a82910b
[planar] Reading data on C++ code
cvvergara Jan 24, 2024
494befa
[topologicalSort] Reading data on C++ code
cvvergara Jan 24, 2024
7641069
[transitiveClosure] Reading data on C++ code
cvvergara Jan 24, 2024
0e538d5
[traversal] Reading data on C++ code
cvvergara Jan 24, 2024
9b33d69
[trsp] Reading data on C++ code
cvvergara Jan 24, 2024
7c47b4d
[tsp] Reading data on C++ code
cvvergara Jan 24, 2024
f906f94
[withPoints] Reading data on C++ code
cvvergara Jan 24, 2024
30a2fea
[spannTree] Reading data on C++ code
cvvergara Jan 24, 2024
157fb75
[spannTree] fix failing tests
cvvergara Jan 24, 2024
47f9f55
[bellman_ford] Fixing codacy errors
cvvergara Jan 25, 2024
c3c5cf0
[breadthFirstSearch] Fixing codacy errors
cvvergara Jan 25, 2024
64841bb
[max_flow] Fixing codacy errors
cvvergara Jan 25, 2024
e2ce6b7
[trsp] Fixing codacy errors
cvvergara Jan 25, 2024
3be0767
[trsp_pgget] marking unused code
cvvergara Jan 25, 2024
cbf60e5
[trsp_pgfetch] marking unused code
cvvergara Jan 25, 2024
63738d9
[pgdata_fetchers.cpp] Fixing codacy errors
cvvergara Jan 25, 2024
9d15f48
[planar] Reading data on C++ code
cvvergara Jan 30, 2024
277e8be
[trsp_pgget trsp_pgfetch] Removing unused code
cvvergara Jan 30, 2024
184de78
[doc] Updating NEWS & release_notes
cvvergara Jan 30, 2024
803d89b
[breadthFirstSearch] Fixing codacy errors
cvvergara Jan 31, 2024
32be7d0
[chinese] Fixing codacy errors
cvvergara Jan 31, 2024
4a6b2dd
[mincut] Fixing codacy errors
cvvergara Jan 31, 2024
7efd728
[max_flow] Fixing codacy errors
cvvergara Jan 31, 2024
97c87c4
[trsp] Fixing codacy errors
cvvergara Jan 31, 2024
d6585aa
[planar] Fixing codacy errors
cvvergara Jan 31, 2024
deaeedc
fixing issue with code checker
cvvergara Jan 31, 2024
e3a10ed
using tag 1.6.1 on cpplint
cvvergara Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'cpplint/cpplint'
ref: "develop"
ref: "1.6.1"
path: "code_linter/cpplint"
- name: Run linter
run: |
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ milestone for 3.7.0

* [#2599](https://github.com/pgRouting/pgrouting/pull/2599) Driving distance
cleanup
* [#2607](https://github.com/pgRouting/pgrouting/pull/2607) Read postgresql
data on C++

**Others**

Expand Down
2 changes: 2 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ milestone for 3.7.0

* `#2599 <https://github.com/pgRouting/pgrouting/pull/2599>`__ Driving distance
cleanup
* `#2607 <https://github.com/pgRouting/pgrouting/pull/2607>`__ Read postgresql
data on C++

.. rubric:: Others

Expand Down
4 changes: 2 additions & 2 deletions docqueries/bdAstar/doc-pgr_bdAstar.result
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ SELECT * FROM pgr_bdAstar(
5 | 5 | 6 | 10 | 15 | 3 | 1 | 4
6 | 6 | 6 | 10 | 10 | -1 | 0 | 5
7 | 1 | 6 | 12 | 6 | 4 | 1 | 0
8 | 2 | 6 | 12 | 7 | 10 | 1 | 1
9 | 3 | 6 | 12 | 8 | 12 | 1 | 2
8 | 2 | 6 | 12 | 7 | 8 | 1 | 1
9 | 3 | 6 | 12 | 11 | 11 | 1 | 2
10 | 4 | 6 | 12 | 12 | -1 | 0 | 3
11 | 1 | 8 | 10 | 8 | 10 | 1 | 0
12 | 2 | 8 | 10 | 7 | 8 | 1 | 1
Expand Down
2 changes: 2 additions & 0 deletions docqueries/lineGraph/pgtap_design_lineGraphFull.result
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ SELECT id FROM vertices;
SELECT * FROM pgr_lineGraphFull(
$$SELECT id, source, target, cost FROM edges WHERE id = 1$$
);
NOTICE: No edges found
HINT: SELECT id, source, target, cost FROM edges WHERE id = 1
seq | source | target | cost | edge
-----+--------+--------+------+------
(0 rows)
Expand Down
1 change: 1 addition & 0 deletions docqueries/topologicalSort/doc-topologicalSort.result
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ SELECT * FROM pgr_topologicalsort(
SELECT * FROM pgr_topologicalsort(
$$SELECT id, source, target, cost, reverse_cost FROM edges$$);
ERROR: Graph is not DAG
HINT:
CONTEXT: SQL function "pgr_topologicalsort" statement 1
/* -- q4 */
ROLLBACK;
Expand Down
2 changes: 1 addition & 1 deletion include/allpairs/pgr_allpairs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "c_types/iid_t_rt.h"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/interruption.h"
#include "cpp_common/interruption.hpp"

// TODO(vicky) don't keep it here
#include "cpp_common/pgr_alloc.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/astar/astar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "visitors/astar_visitors.hpp"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/interruption.h"
#include "cpp_common/interruption.hpp"
#include "c_types/ii_t_rt.h"

namespace detail {
Expand Down
57 changes: 38 additions & 19 deletions include/bellman_ford/pgr_bellman_ford.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*PGR-GNU*****************************************************************
File: pgr_bellman_ford.hpp

Copyright (c) 2015 pgRouting developers
Mail: project@pgrouting.org
Expand Down Expand Up @@ -43,22 +44,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "cpp_common/pgr_messages.h"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/interruption.h"
#include "cpp_common/interruption.hpp"
#include "c_types/ii_t_rt.h"




//******************************************
namespace pgrouting {

template < class G >
class Pgr_bellman_ford : public pgrouting::Pgr_messages {
public:
typedef typename G::V V;
typedef typename G::E E;
//@}
//@{

#if 0
//! @name BellmanFord
//@{
//! BellmanFord 1 to 1
Expand Down Expand Up @@ -94,39 +92,40 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
predecessors, distances,
only_cost, true);
}
#endif


/** @brief bellman_ford one to a set of many
* @todo document this function
*/

//! BellmanFord 1 to many
std::deque<Path> bellman_ford(
G &graph,
int64_t start_vertex,
const std::vector< int64_t > &end_vertex,
const std::set<int64_t> &end_vertex,
bool only_cost = false) {
// adjust predecessors and distances vectors
clear();
log << std::string(__FUNCTION__) << "\n";
predecessors.resize(graph.num_vertices());
distances.resize(graph.num_vertices());

// get the graphs source and target
if (!graph.has_vertex(start_vertex))
return std::deque<Path>();
// get the graphs source and targets
if (!graph.has_vertex(start_vertex)) return std::deque<Path>();
auto v_source(graph.get_V(start_vertex));

std::set< V > s_v_targets;
std::set<V> s_v_targets;
for (const auto &vertex : end_vertex) {
if (graph.has_vertex(vertex)) {
s_v_targets.insert(graph.get_V(vertex));
}
}

std::vector< V > v_targets(s_v_targets.begin(), s_v_targets.end());
std::vector<V> v_targets(s_v_targets.begin(), s_v_targets.end());
// perform the algorithm
bellman_ford_1_to_many(graph, v_source);

std::deque< Path > paths;
// get the results // route id are the targets
paths = get_paths(graph, v_source, v_targets, only_cost);
auto paths = get_paths(graph, v_source, v_targets, only_cost);

std::stable_sort(paths.begin(), paths.end(),
[](const Path &e1, const Path &e2)->bool {
Expand All @@ -136,6 +135,7 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
return paths;
}

#if 0
// BellmanFord many to 1
std::deque<Path> bellman_ford(
G &graph,
Expand Down Expand Up @@ -219,10 +219,28 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {

return paths;
}
#endif

/** @brief BellmanFord combinations **/
std::deque<Path> bellman_ford(
G &graph,
const std::map<int64_t, std::set<int64_t>> &combinations,
bool only_cost = false) {
std::deque<Path> paths;

for (const auto &comb : combinations) {
if (!graph.has_vertex(comb.first)) continue;
auto tmp_paths = bellman_ford(graph, comb.first, comb.second, only_cost);
paths.insert(paths.end(), tmp_paths.begin(), tmp_paths.end());
}

return paths;
}

//@}

private:
#if 0
//! Call to BellmanFord 1 source to 1 target
bool bellman_ford_1_to_1(
G &graph,
Expand Down Expand Up @@ -250,6 +268,8 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
}
return true;
}
#endif

//! Call to BellmanFord 1 source to many targets
bool bellman_ford_1_to_many(
G &graph,
Expand Down Expand Up @@ -291,7 +311,6 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
V source,
std::vector< V > &targets,
bool only_cost) const {
log << std::string(__FUNCTION__) << "\n";
std::deque<Path> paths;
for (const auto target : targets) {
paths.push_back(Path(
Expand All @@ -307,8 +326,8 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {

//! @name members
//@{
std::vector< V > predecessors;
std::vector< double > distances;
std::vector<V> predecessors;
std::vector<double> distances;

//@}
};
Expand Down
41 changes: 33 additions & 8 deletions include/bellman_ford/pgr_edwardMoore.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*PGR-GNU*****************************************************************
File: pgr_edwardMoore.hpp

Copyright (c) 2019 pgRouting developers
Mail: project@pgrouting.org

Copyright (c) 2019 Gudesa Venkata Sai AKhil
Mail: gvs.akhil1997@gmail.com
------
Expand All @@ -26,11 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>

#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/interruption.h"
#include "cpp_common/interruption.hpp"

#include "c_types/ii_t_rt.h"

Expand All @@ -42,10 +45,9 @@ class Pgr_edwardMoore {
public:
typedef typename G::V V;
typedef typename G::E E;
typedef typename G::B_G B_G;
typedef typename G::EO_i EO_i;
typedef typename G::E_i E_i;

#if 0
std::deque<Path> edwardMoore(
G &graph,
const std::vector<int64_t> &start_vertex,
Expand Down Expand Up @@ -117,14 +119,37 @@ class Pgr_edwardMoore {

return paths;
}
#endif

/** @brief edwardMoore for combinations */
std::deque<Path> edwardMoore(
G &graph,
const std::map<int64_t, std::set<int64_t>> &combinations) {
std::deque<Path> paths;

for (const auto &comb : combinations) {
if (!graph.has_vertex(comb.first)) continue;
auto tmp_paths = one_to_many_edwardMoore(graph, comb.first, comb.second);
paths.insert(paths.end(), tmp_paths.begin(), tmp_paths.end());
}
std::sort(paths.begin(), paths.end(),
[](const Path &e1, const Path &e2) -> bool {
return e1.end_id() < e2.end_id();
});
std::stable_sort(paths.begin(), paths.end(),
[](const Path &e1, const Path &e2) -> bool {
return e1.start_id() < e2.start_id();
});
return paths;
}

private:
E DEFAULT_EDGE;
E default_edge;

std::deque<Path> one_to_many_edwardMoore(
G &graph,
int64_t start_vertex,
std::vector<int64_t> end_vertex) {
const std::set<int64_t> &end_vertex) {
std::deque<Path> paths;

if (graph.has_vertex(start_vertex) == false) {
Expand All @@ -135,7 +160,7 @@ class Pgr_edwardMoore {
std::vector<bool> isInQ(graph.num_vertices(), false);
std::vector<E> from_edge(graph.num_vertices());
std::deque<V> dq;
DEFAULT_EDGE = from_edge[0];
default_edge = from_edge[0];

auto bgl_start_vertex = graph.get_V(start_vertex);

Expand All @@ -159,7 +184,7 @@ class Pgr_edwardMoore {

auto bgl_target_vertex = graph.get_V(target_vertex);

if (from_edge[bgl_target_vertex] == DEFAULT_EDGE) {
if (from_edge[bgl_target_vertex] == default_edge) {
continue;
}

Expand Down Expand Up @@ -192,7 +217,7 @@ class Pgr_edwardMoore {
path.push_back({graph[from].id, graph[e].id, graph[e].cost, current_cost[from], 0});

current_node = from;
} while (from_edge[current_node] != DEFAULT_EDGE);
} while (from_edge[current_node] != default_edge);

std::reverse(path.begin(), path.end());
return path;
Expand Down
Loading
Loading