Skip to content

Commit

Permalink
Merge pull request #1081 from codeSG/dag_bellman_parallel
Browse files Browse the repository at this point in the history
Implemented functions for GSoC'18
  • Loading branch information
codeSG committed Aug 1, 2018
2 parents 3daf896 + de802aa commit 28d3cf5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
18 changes: 8 additions & 10 deletions include/dagShortestPath/pgr_dagShortestPath.hpp
Expand Up @@ -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<size_t>::max()) {
bool only_cost) {
// adjust predecessors and distances vectors
clear();

size_t n_goals = std::numeric_limits<size_t>::max();
predecessors.resize(graph.num_vertices());
distances.resize(
graph.num_vertices(),
Expand Down Expand Up @@ -156,16 +155,15 @@ 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<size_t>::max()) {
bool only_cost) {
// a call to 1 to many is faster for each of the sources
std::deque<Path> paths;

for (const auto &start : start_vertex) {
auto r_paths = dag(
graph,
start, end_vertex,
only_cost, n_goals);
only_cost);
paths.insert(paths.begin(), r_paths.begin(), r_paths.end());
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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<double>::infinity())
);
.visitor(dijkstra_many_goal_visitor(targets, n_goals)));
} catch(found_goals &) {
return true;
} catch (boost::exception const& ex) {
Expand Down Expand Up @@ -273,7 +271,7 @@ class Pgr_dag {
std::ostringstream log;
//@}

/*

//! @name Stopping classes
//@{
//! class for stopping when 1 target is found
Expand Down Expand Up @@ -317,7 +315,7 @@ class Pgr_dag {
std::set< V > m_goals;
size_t m_n_goals;
};
*/

};

#endif // INCLUDE_DIJKSTRA_PGR_DIJKSTRA_HPP_
@@ -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',
Expand Down Expand Up @@ -46,8 +48,8 @@ SELECT * FROM pgr_dagShortestPath(

-- q4
SELECT * FROM pgr_dagShortestPath(
'SELECT id, source, target, cost FROM edge_table2',
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
-----+----------+------+------+------+----------
Expand Down
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/dagShortestPath/test.conf
Expand Up @@ -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
)]
},

Expand Down

0 comments on commit 28d3cf5

Please sign in to comment.