Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To see all issues & pull requests closed by this release see the
* [#3054](https://github.com/pgRouting/pgrouting/issues/3054): Change error message when edges_sql is empty
* [#3055](https://github.com/pgRouting/pgrouting/issues/3055): bdDijkstra: use the shortest_path process and driver
* [#3056](https://github.com/pgRouting/pgrouting/issues/3056): edwardMoore: use the shortest_path process and driver
* [#3060](https://github.com/pgRouting/pgrouting/issues/3060): dagShortestPath: use the shortest_path process and driver

## pgRouting 4.0

Expand Down
1 change: 1 addition & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ To see all issues & pull requests closed by this release see the
* :issue:`3054`: Change error message when edges_sql is empty
* :issue:`3055`: bdDijkstra: use the shortest_path process and driver
* :issue:`3056`: edwardMoore: use the shortest_path process and driver
* :issue:`3060`: dagShortestPath: use the shortest_path process and driver

pgRouting 4.0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
1 change: 1 addition & 0 deletions include/c_common/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum Which {
TOPOSORT = 11,
/** shortest_paths */
DIJKSTRA = 21, WITHPOINTS, OLD_WITHPOINTS, BDDIJKSTRA, EDWARDMOORE,
DAGSP,
/** allpairs **/
FLOYD = 31, JOHNSON,
/** metrics **/
Expand Down
14 changes: 14 additions & 0 deletions include/dagShortestPath/dagShortestPath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ class Pgr_dag {
};
};

namespace algorithms {

template <class G>
std::deque<pgrouting::Path>
dagShortestPath(
G &graph,
std::map<int64_t, std::set<int64_t>> &combinations,
bool only_cost = false) {
pgrouting::Pgr_dag<G> fn_dag;
auto paths = fn_dag.dag(graph, combinations, only_cost);
return paths;
}

} // namespace algorithms
Comment thread
cvvergara marked this conversation as resolved.
} // namespace pgrouting

#endif // INCLUDE_DAGSHORTESTPATH_DAGSHORTESTPATH_HPP_
76 changes: 0 additions & 76 deletions include/drivers/dagShortestPath/dagShortestPath_driver.h

This file was deleted.

7 changes: 6 additions & 1 deletion locale/en/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pgRouting v4.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-06 17:38+0000\n"
"POT-Creation-Date: 2026-02-07 19:07+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -3946,6 +3946,11 @@ msgid ""
"use the shortest_path process and driver"
msgstr ""

msgid ""
"`#3060 <https://github.com/pgRouting/pgrouting/issues/3060>`__: "
"dagShortestPath: use the shortest_path process and driver"
msgstr ""

msgid "All releases"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion locale/pot/pgrouting_doc_strings.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pgRouting v4.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-06 17:38+0000\n"
"POT-Creation-Date: 2026-02-07 19:07+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -3541,6 +3541,9 @@ msgstr ""
msgid "`#3056 <https://github.com/pgRouting/pgrouting/issues/3056>`__: edwardMoore: use the shortest_path process and driver"
msgstr ""

msgid "`#3060 <https://github.com/pgRouting/pgrouting/issues/3060>`__: dagShortestPath: use the shortest_path process and driver"
msgstr ""

msgid "All releases"
msgstr ""

Expand Down
3 changes: 2 additions & 1 deletion pgtap/others/dagShortestPath/no_crash_test.pg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
BEGIN;

UPDATE edges SET cost = sign(cost), reverse_cost = -sign(cost);
SELECT CASE WHEN min_version('4.0.0') THEN plan(81) ELSE plan(1) END;
SELECT CASE WHEN min_version('4.0.0') THEN plan(82) ELSE plan(1) END;

CREATE OR REPLACE FUNCTION no_crash()
RETURNS SETOF TEXT AS
Expand Down Expand Up @@ -135,6 +135,7 @@ BEGIN
'NULL::TEXT'
]::TEXT[];
RETURN query SELECT * FROM no_crash_test('pgr_dagShortestPath', params, subs);
RETURN query SELECT throw_on_empty_edges_sql('pgr_dagShortestPath', ',1,5');

END
$BODY$
Expand Down
10 changes: 4 additions & 6 deletions src/cpp_common/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ get_name(Which which, bool is_only_cost, bool is_near, bool is_matrix) {
case EDWARDMOORE:
base = "pgr_edwardMoore";
break;
case DAGSP :
base = "pgr_dagShortestPath";
break;
case OLD_WITHPOINTS:
case WITHPOINTS:
base = "pgr_withPoints";
Expand All @@ -96,26 +99,21 @@ estimate_drivingSide(char driving_side, Which which) {
d_side = ' ';
}
switch (which) {
case DAGSP :
case EDWARDMOORE:
case BDDIJKSTRA:
case DIJKSTRA:
{
return ' ';
break;
}
case WITHPOINTS:
{
if (d_side == ' ') {
throw std::make_pair(std::string("Invalid value of 'driving side'"),
std::string("Valid value are 'r', 'l', 'b'"));
}
break;
}
default:
{
/* For the moment its old signature of pgr_withPoints */
if (!((d_side == 'r') || (d_side == 'l'))) d_side = 'b';
}
}
return d_side;
}
Expand Down
3 changes: 1 addition & 2 deletions src/dagShortestPath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# License: GPL-2 See https://github.com/pgRouting/pgrouting/blob/main/LICENSE
ADD_LIBRARY(dagShortestPath OBJECT
dagShortestPath.c
dagShortestPath_driver.cpp
)
)
78 changes: 27 additions & 51 deletions src/dagShortestPath/dagShortestPath.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,59 +30,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include <stdbool.h>
#include "c_common/postgres_connection.h"

#include "c_types/path_rt.h"
#include "c_common/debug_macro.h"
#include "c_common/e_report.h"
#include "c_common/time_msg.h"
#include "drivers/dagShortestPath/dagShortestPath_driver.h"
#include "process/shortestPath_process.h"

PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(_pgr_dagshortestpath_v4);


static
void
process(
char* edges_sql,
char* combinations_sql,
ArrayType *starts,
ArrayType *ends,
bool only_cost,
bool normal,
Path_rt **result_tuples,
size_t *result_count) {
pgr_SPI_connect();
char* log_msg = NULL;
char* notice_msg = NULL;
char* err_msg = NULL;
(*result_tuples) = NULL;
(*result_count) = 0;

clock_t start_t = clock();
pgr_do_dagShortestPath(
edges_sql,
combinations_sql,
starts, ends,

only_cost,
normal,

result_tuples,
result_count,
&log_msg,
&notice_msg,
&err_msg);
time_msg(" processing pgr_dagShortestPath", start_t, clock());

if (err_msg) {
if (*result_tuples) pfree(*result_tuples);
}
pgr_global_report(&log_msg, &notice_msg, &err_msg);

pgr_SPI_finish();
}

PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) {
FuncCallContext *funcctx;
TupleDesc tuple_desc;
Expand All @@ -99,26 +52,48 @@ PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) {
/*
* many to many
*/
process(
pgr_process_shortestPath(
text_to_cstring(PG_GETARG_TEXT_P(0)),
NULL,
NULL,

PG_GETARG_ARRAYTYPE_P(1),
PG_GETARG_ARRAYTYPE_P(2),

true,
PG_GETARG_BOOL(3),
PG_GETARG_BOOL(4),

0,
true,
' ',
true,

DAGSP,
&result_tuples,
&result_count);

} else if (PG_NARGS() == 3) {
/*
* combinations
*/
process(
pgr_process_shortestPath(
text_to_cstring(PG_GETARG_TEXT_P(0)),
NULL,
text_to_cstring(PG_GETARG_TEXT_P(1)),

NULL, NULL,

true,
PG_GETARG_BOOL(2),
true,

0,
true,
' ',
true,

DAGSP,
&result_tuples,
&result_count);
}
Expand All @@ -129,7 +104,8 @@ PGDLLEXPORT Datum _pgr_dagshortestpath_v4(PG_FUNCTION_ARGS) {
!= TYPEFUNC_COMPOSITE) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in context that cannot accept type record")));
errmsg("function returning record called in context "
"that cannot accept type record")));
}

funcctx->tuple_desc = tuple_desc;
Expand Down
Loading