From ba2a60cfff1141f81ac0f3acb77c471b58bac718 Mon Sep 17 00:00:00 2001 From: codeSG Date: Wed, 1 Aug 2018 19:50:03 +0530 Subject: [PATCH 1/3] [dagShortestPath] fix issues and warnings --- .../dagShortestPath/pgr_dagShortestPath.hpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/include/dagShortestPath/pgr_dagShortestPath.hpp b/include/dagShortestPath/pgr_dagShortestPath.hpp index e668050e26c..da3b4df4065 100644 --- a/include/dagShortestPath/pgr_dagShortestPath.hpp +++ b/include/dagShortestPath/pgr_dagShortestPath.hpp @@ -91,11 +91,10 @@ class Pgr_dag { G &graph, int64_t start_vertex, const std::vector< int64_t > &end_vertex, - bool only_cost, - size_t n_goals = std::numeric_limits::max()) { + bool only_cost) { // adjust predecessors and distances vectors clear(); - + size_t n_goals = std::numeric_limits::max(); predecessors.resize(graph.num_vertices()); distances.resize( graph.num_vertices(), @@ -156,8 +155,7 @@ class Pgr_dag { G &graph, const std::vector< int64_t > &start_vertex, const std::vector< int64_t > &end_vertex, - bool only_cost, - size_t n_goals = std::numeric_limits::max()) { + bool only_cost) { // a call to 1 to many is faster for each of the sources std::deque paths; @@ -165,7 +163,7 @@ class Pgr_dag { auto r_paths = dag( graph, start, end_vertex, - only_cost, n_goals); + only_cost); paths.insert(paths.begin(), r_paths.begin(), r_paths.end()); } @@ -193,7 +191,7 @@ class Pgr_dag { boost::predecessor_map(&predecessors[0]) .weight_map(get(&G::G_T_E::cost, graph.graph)) .distance_map(&distances[0]) - ); + .visitor(dijkstra_one_goal_visitor(target))); } catch(found_goals &) { return true; } catch (boost::exception const& ex) { @@ -220,7 +218,7 @@ class Pgr_dag { .weight_map(get(&G::G_T_E::cost, graph.graph)) .distance_map(&distances[0]) .distance_inf(std::numeric_limits::infinity()) - ); + .visitor(dijkstra_many_goal_visitor(targets, n_goals))); } catch(found_goals &) { return true; } catch (boost::exception const& ex) { @@ -273,7 +271,7 @@ class Pgr_dag { std::ostringstream log; //@} - /* + //! @name Stopping classes //@{ //! class for stopping when 1 target is found @@ -317,7 +315,7 @@ class Pgr_dag { std::set< V > m_goals; size_t m_n_goals; }; - */ + }; #endif // INCLUDE_DIJKSTRA_PGR_DIJKSTRA_HPP_ From 67bcf498c525134ec511f7dcae3fefa655bcbe69 Mon Sep 17 00:00:00 2001 From: codeSG Date: Wed, 1 Aug 2018 20:16:16 +0530 Subject: [PATCH 2/3] [dagShortestPath] fix test files --- test/dagShortestPath/doc-dagShortestPath.result | 2 +- test/dagShortestPath/doc-dagShortestPath.test.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dagShortestPath/doc-dagShortestPath.result b/test/dagShortestPath/doc-dagShortestPath.result index 84e3f53a59f..c434e07fd4e 100644 --- a/test/dagShortestPath/doc-dagShortestPath.result +++ b/test/dagShortestPath/doc-dagShortestPath.result @@ -46,7 +46,7 @@ SELECT * FROM pgr_dagShortestPath( -- q4 SELECT * FROM pgr_dagShortestPath( -'SELECT id, source, target, cost FROM edge_table2', +'SELECT id, source, target, cost FROM edge_table', ARRAY[1, 4],ARRAY[12,6] ); seq | path_seq | node | edge | cost | agg_cost diff --git a/test/dagShortestPath/doc-dagShortestPath.test.sql b/test/dagShortestPath/doc-dagShortestPath.test.sql index 854e9682558..699621a1db5 100644 --- a/test/dagShortestPath/doc-dagShortestPath.test.sql +++ b/test/dagShortestPath/doc-dagShortestPath.test.sql @@ -7,7 +7,7 @@ SELECT * FROM pgr_dagShortestPath( \echo -- q2 SELECT * FROM pgr_dagShortestPath( - 'SELECT id, source, target, costt FROM edge_table', + 'SELECT id, source, target, cost FROM edge_table', 1, ARRAY[5,6] ); \echo -- q3 From de802aa16f59e2928ff17380b4f4f441538472ea Mon Sep 17 00:00:00 2001 From: codeSG Date: Wed, 1 Aug 2018 21:23:35 +0530 Subject: [PATCH 3/3] [dagShortestPath] fixing bugs in test files --- ...agShortestPath.result => doc-pgr_dagShortestPath.result} | 6 ++++-- ...ortestPath.test.sql => doc-pgr_dagShortestPath.test.sql} | 0 test/dagShortestPath/test.conf | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) rename test/dagShortestPath/{doc-dagShortestPath.result => doc-pgr_dagShortestPath.result} (94%) rename test/dagShortestPath/{doc-dagShortestPath.test.sql => doc-pgr_dagShortestPath.test.sql} (100%) diff --git a/test/dagShortestPath/doc-dagShortestPath.result b/test/dagShortestPath/doc-pgr_dagShortestPath.result similarity index 94% rename from test/dagShortestPath/doc-dagShortestPath.result rename to test/dagShortestPath/doc-pgr_dagShortestPath.result index c434e07fd4e..f008a84a052 100644 --- a/test/dagShortestPath/doc-dagShortestPath.result +++ b/test/dagShortestPath/doc-pgr_dagShortestPath.result @@ -1,5 +1,7 @@ BEGIN; BEGIN +SET client_min_messages TO NOTICE; +SET -- q1 SELECT * FROM pgr_dagShortestPath( 'SELECT id, source, target, cost FROM edge_table', @@ -46,8 +48,8 @@ SELECT * FROM pgr_dagShortestPath( -- q4 SELECT * FROM pgr_dagShortestPath( -'SELECT id, source, target, cost FROM edge_table', -ARRAY[1, 4],ARRAY[12,6] + 'SELECT id, source, target, cost FROM edge_table', + ARRAY[1, 4],ARRAY[12,6] ); seq | path_seq | node | edge | cost | agg_cost -----+----------+------+------+------+---------- diff --git a/test/dagShortestPath/doc-dagShortestPath.test.sql b/test/dagShortestPath/doc-pgr_dagShortestPath.test.sql similarity index 100% rename from test/dagShortestPath/doc-dagShortestPath.test.sql rename to test/dagShortestPath/doc-pgr_dagShortestPath.test.sql diff --git a/test/dagShortestPath/test.conf b/test/dagShortestPath/test.conf index 17b38e49faf..74bcbc9987a 100644 --- a/test/dagShortestPath/test.conf +++ b/test/dagShortestPath/test.conf @@ -2,13 +2,13 @@ %main::tests = ( 'any' => { - 'comment' => 'Dijkstra test for any versions.', + 'comment' => 'pgr_dagShortestPath', 'data' => [ ], 'tests' => [qw( - doc-dagShortestPath + doc-pgr_dagShortestPath )], 'documentation' => [qw( - doc-dagShortestPath + doc-pgr_dagShortestPath )] },