diff --git a/NEWS.md b/NEWS.md index 957d0a6c4ac..ec6d2b7e752 100644 --- a/NEWS.md +++ b/NEWS.md @@ -93,6 +93,11 @@ To see all issues & pull requests closed by this release see the 4.1.0 Bug Fixes * [#3101](https://github.com/pgRouting/pgrouting/issues/3101): pgr_edgeColoring not building graph correctly +* [#3180](https://github.com/pgRouting/pgrouting/issues/3180): On undirected graphs where cost and reverse_cost differ, + pgr_aStar, pgr_aStarCost, pgr_aStarCostMatrix, pgr_bdAstar, + pgr_bdAstarCost, pgr_bdAstarCostMatrix, pgr_bdDijkstra, + pgr_bdDijkstraCost and pgr_bdDijkstraCostMatrix returned every node and + edge twice, with both costs added up 4.1.0 Requirements diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 2342eb1412f..16cb32df16b 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -134,6 +134,11 @@ To see all issues & pull requests closed by this release see the ............................................................................... * :issue:`3101`: pgr_edgeColoring not building graph correctly +* :issue:`3180`: On undirected graphs where cost and reverse_cost differ, + pgr_aStar, pgr_aStarCost, pgr_aStarCostMatrix, pgr_bdAstar, + pgr_bdAstarCost, pgr_bdAstarCostMatrix, pgr_bdDijkstra, + pgr_bdDijkstraCost and pgr_bdDijkstraCostMatrix returned every node and + edge twice, with both costs added up 4.1.0 Requirements ............................................................................... diff --git a/include/cpp_common/path.hpp b/include/cpp_common/path.hpp index 76ac05fb4c0..d7253cf9ad8 100644 --- a/include/cpp_common/path.hpp +++ b/include/cpp_common/path.hpp @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include #include +#include #include "cpp_common/undefPostgresDefine.hpp" @@ -193,12 +194,35 @@ class Path { /* TODO(v4) add correct predecessor node */ path.push_back({m_end_id, -1, 0, 0, 0}); } else { + /* + * An undirected edge whose cost and reverse_cost are + * both non negative and different is stored as two + * internal edges that share the same id, so more than + * one out-edge here can match p.edge. See base_graph.hpp + * graph_add_edge and doc/src/pgRouting-concepts.rst + * + * Keep one row for this step: the edge that costs what + * this step costs, otherwise the cheapest of the + * matching edges. Same rule as + * Pgr_base_graph::get_edge_id + */ + bool found = false; + double chosen = (std::numeric_limits::max)(); for ( ; ei != ei_end; ++ei) { - if (graph[*ei].id == p.edge) { - auto cost = graph[*ei].cost; - /* TODO(v4) add correct predecessor node */ - push_back({p.node, p.edge, cost, 0, 0}); + if (graph[*ei].id != p.edge) continue; + if (graph[*ei].cost == p.cost) { + chosen = graph[*ei].cost; + found = true; + break; } + if (graph[*ei].cost < chosen) { + chosen = graph[*ei].cost; + found = true; + } + } + if (found) { + /* TODO(v4) add correct predecessor node */ + push_back({p.node, p.edge, chosen, 0, 0}); } } // last_node = p.node; diff --git a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po index 3e347d78afe..e5b46b78222 100644 --- a/locale/en/LC_MESSAGES/pgrouting_doc_strings.po +++ b/locale/en/LC_MESSAGES/pgrouting_doc_strings.po @@ -3798,6 +3798,9 @@ msgstr "" msgid ":issue:`3101`: pgr_edgeColoring not building graph correctly" msgstr "" +msgid ":issue:`3180`: On undirected graphs where cost and reverse_cost differ, pgr_aStar, pgr_aStarCost, pgr_aStarCostMatrix, pgr_bdAstar, pgr_bdAstarCost, pgr_bdAstarCostMatrix, pgr_bdDijkstra, pgr_bdDijkstraCost and pgr_bdDijkstraCostMatrix returned every node and edge twice, with both costs added up" +msgstr "" + msgid "4.1.0 Requirements" msgstr "" diff --git a/locale/pot/pgrouting_doc_strings.pot b/locale/pot/pgrouting_doc_strings.pot index ef00480f8a0..cbb533ae875 100644 --- a/locale/pot/pgrouting_doc_strings.pot +++ b/locale/pot/pgrouting_doc_strings.pot @@ -3784,6 +3784,9 @@ msgstr "" msgid ":issue:`3101`: pgr_edgeColoring not building graph correctly" msgstr "" +msgid ":issue:`3180`: On undirected graphs where cost and reverse_cost differ, pgr_aStar, pgr_aStarCost, pgr_aStarCostMatrix, pgr_bdAstar, pgr_bdAstarCost, pgr_bdAstarCostMatrix, pgr_bdDijkstra, pgr_bdDijkstraCost and pgr_bdDijkstraCostMatrix returned every node and edge twice, with both costs added up" +msgstr "" + msgid "4.1.0 Requirements" msgstr "" diff --git a/pgtap/astar/edge_cases/issue_3180.pg b/pgtap/astar/edge_cases/issue_3180.pg new file mode 100644 index 00000000000..a59b6b72427 --- /dev/null +++ b/pgtap/astar/edge_cases/issue_3180.pg @@ -0,0 +1,124 @@ +/* :file: This file is part of the pgRouting project. +:copyright: Copyright (c) 2026-2026 pgRouting developers +:license: Creative Commons Attribution-Share Alike 3.0 https://creativecommons.org/licenses/by-sa/3.0 */ + + +/* + * Issue #3180: undirected graph where cost and reverse_cost differ + * + * On an undirected graph an edge whose cost and reverse_cost are both non + * negative and different is kept as two internal edges that share the same + * id. pgr_aStar, pgr_aStarCost and pgr_aStarCostMatrix returned a row for + * each of them, so every node and edge came back twice and agg_cost added + * both weights. The pgr_dijkstra family uses each edge once and is the + * reference here. + * + * The chain below costs 7 one way and 2 the other, so the cheapest route + * from 1 to 6 uses each edge once at cost 2: 6 rows and agg_cost 10. + * The nodes sit on a line one unit apart, so the heuristic never overestimates. + */ + +BEGIN; + +SET extra_float_digits=-3; + +SELECT CASE WHEN min_version('4.1.0') THEN plan(13) ELSE plan(1) END; + +/* builds: SELECT FROM ('SELECT FROM ', , ) */ +CREATE OR REPLACE FUNCTION issue_3180_q( + fn TEXT, cols TEXT, incols TEXT, tbl TEXT, verts TEXT, flag TEXT, extra TEXT) +RETURNS TEXT AS +$BODY$ + SELECT 'SELECT ' || cols || ' FROM ' || fn || '(''SELECT ' || incols + || ' FROM ' || tbl || ''', ' || verts || ', ' || flag || extra || ')'; +$BODY$ +LANGUAGE sql IMMUTABLE; + +/* the same four checks for one function: the bug, then the two controls */ +CREATE OR REPLACE FUNCTION issue_3180_variant( + fn TEXT, ref TEXT, cols TEXT, verts TEXT, h0 TEXT, h5 TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + inc TEXT := 'id, source, target, cost, reverse_cost, x1, y1, x2, y2'; + rinc TEXT := 'id, source, target, cost, reverse_cost'; +BEGIN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h0), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected must match ' || ref || ' (agg_cost 10)'); + + IF h5 IS NOT NULL THEN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h5), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected with heuristic 5 must match ' || ref || ' (agg_cost 10)'); + END IF; + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'true', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'true', ''), + fn || ': control, directed matches ' || ref || ' (agg_cost 35)'); + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180_sym', verts, 'false', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180_sym', verts, 'false', ''), + fn || ': control, cost = reverse_cost matches ' || ref || ' (agg_cost 35)'); +END; +$BODY$ +LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION issue_3180_tests() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN + + IF NOT min_version('4.1.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_aStar: Fix implemented on 4.1.0'); + RETURN; + END IF; + + CREATE TEMP TABLE edges_3180 AS + SELECT * FROM (VALUES + (1::BIGINT, 1::BIGINT, 2::BIGINT, 7::FLOAT, 2::FLOAT, 0::FLOAT, 0::FLOAT, 1::FLOAT, 0::FLOAT), + (2::BIGINT, 2::BIGINT, 3::BIGINT, 7::FLOAT, 2::FLOAT, 1::FLOAT, 0::FLOAT, 2::FLOAT, 0::FLOAT), + (3::BIGINT, 3::BIGINT, 4::BIGINT, 7::FLOAT, 2::FLOAT, 2::FLOAT, 0::FLOAT, 3::FLOAT, 0::FLOAT), + (4::BIGINT, 4::BIGINT, 5::BIGINT, 7::FLOAT, 2::FLOAT, 3::FLOAT, 0::FLOAT, 4::FLOAT, 0::FLOAT), + (5::BIGINT, 5::BIGINT, 6::BIGINT, 7::FLOAT, 2::FLOAT, 4::FLOAT, 0::FLOAT, 5::FLOAT, 0::FLOAT) + ) AS t(id, source, target, cost, reverse_cost, x1, y1, x2, y2); + + /* the same chain with one weight for both directions */ + CREATE TEMP TABLE edges_3180_sym AS + SELECT id, source, target, cost, cost AS reverse_cost, x1, y1, x2, y2 FROM edges_3180; + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_aStar', 'pgr_dijkstra', + 'seq, node, edge, cost, agg_cost', '1::BIGINT, 6::BIGINT', + ', 0, 1::FLOAT, 1::FLOAT', ', 5, 1::FLOAT, 1::FLOAT'); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_aStarCost', 'pgr_dijkstraCost', + 'start_vid, end_vid, agg_cost', '1::BIGINT, 6::BIGINT', + ', 0, 1::FLOAT, 1::FLOAT', ', 5, 1::FLOAT, 1::FLOAT'); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_aStarCostMatrix', 'pgr_dijkstraCostMatrix', + 'start_vid, end_vid, agg_cost', 'ARRAY[1, 6]::BIGINT[]', + ', 0, 1::FLOAT, 1::FLOAT', ', 5, 1::FLOAT, 1::FLOAT'); + + /* one row per step: an edge id must not appear twice */ + RETURN QUERY SELECT is( + (SELECT count(*) - count(DISTINCT edge) FROM pgr_aStar( + 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges_3180', + 1::BIGINT, 6::BIGINT, false, 0, 1::FLOAT, 1::FLOAT) WHERE edge <> -1), + 0::BIGINT, + 'pgr_aStar: no edge id appears twice on the undirected route'); + + DROP TABLE edges_3180; + DROP TABLE edges_3180_sym; + +END; +$BODY$ +LANGUAGE plpgsql; + +SELECT issue_3180_tests(); + +SELECT * FROM finish(); +ROLLBACK; diff --git a/pgtap/bdAstar/edge_cases/issue_3180.pg b/pgtap/bdAstar/edge_cases/issue_3180.pg new file mode 100644 index 00000000000..3557f5f5184 --- /dev/null +++ b/pgtap/bdAstar/edge_cases/issue_3180.pg @@ -0,0 +1,124 @@ +/* :file: This file is part of the pgRouting project. +:copyright: Copyright (c) 2026-2026 pgRouting developers +:license: Creative Commons Attribution-Share Alike 3.0 https://creativecommons.org/licenses/by-sa/3.0 */ + + +/* + * Issue #3180: undirected graph where cost and reverse_cost differ + * + * On an undirected graph an edge whose cost and reverse_cost are both non + * negative and different is kept as two internal edges that share the same + * id. pgr_bdAstar, pgr_bdAstarCost and pgr_bdAstarCostMatrix returned a row for + * each of them, so every node and edge came back twice and agg_cost added + * both weights. The pgr_dijkstra family uses each edge once and is the + * reference here. + * + * The chain below costs 7 one way and 2 the other, so the cheapest route + * from 1 to 6 uses each edge once at cost 2: 6 rows and agg_cost 10. + * The nodes sit on a line one unit apart, so the heuristic never overestimates. + */ + +BEGIN; + +SET extra_float_digits=-3; + +SELECT CASE WHEN min_version('4.1.0') THEN plan(13) ELSE plan(1) END; + +/* builds: SELECT FROM ('SELECT FROM ', , ) */ +CREATE OR REPLACE FUNCTION issue_3180_q( + fn TEXT, cols TEXT, incols TEXT, tbl TEXT, verts TEXT, flag TEXT, extra TEXT) +RETURNS TEXT AS +$BODY$ + SELECT 'SELECT ' || cols || ' FROM ' || fn || '(''SELECT ' || incols + || ' FROM ' || tbl || ''', ' || verts || ', ' || flag || extra || ')'; +$BODY$ +LANGUAGE sql IMMUTABLE; + +/* the same four checks for one function: the bug, then the two controls */ +CREATE OR REPLACE FUNCTION issue_3180_variant( + fn TEXT, ref TEXT, cols TEXT, verts TEXT, h0 TEXT, h5 TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + inc TEXT := 'id, source, target, cost, reverse_cost, x1, y1, x2, y2'; + rinc TEXT := 'id, source, target, cost, reverse_cost'; +BEGIN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h0), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected must match ' || ref || ' (agg_cost 10)'); + + IF h5 IS NOT NULL THEN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h5), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected with heuristic 5 must match ' || ref || ' (agg_cost 10)'); + END IF; + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'true', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'true', ''), + fn || ': control, directed matches ' || ref || ' (agg_cost 35)'); + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180_sym', verts, 'false', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180_sym', verts, 'false', ''), + fn || ': control, cost = reverse_cost matches ' || ref || ' (agg_cost 35)'); +END; +$BODY$ +LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION issue_3180_tests() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN + + IF NOT min_version('4.1.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_bdAstar: Fix implemented on 4.1.0'); + RETURN; + END IF; + + CREATE TEMP TABLE edges_3180 AS + SELECT * FROM (VALUES + (1::BIGINT, 1::BIGINT, 2::BIGINT, 7::FLOAT, 2::FLOAT, 0::FLOAT, 0::FLOAT, 1::FLOAT, 0::FLOAT), + (2::BIGINT, 2::BIGINT, 3::BIGINT, 7::FLOAT, 2::FLOAT, 1::FLOAT, 0::FLOAT, 2::FLOAT, 0::FLOAT), + (3::BIGINT, 3::BIGINT, 4::BIGINT, 7::FLOAT, 2::FLOAT, 2::FLOAT, 0::FLOAT, 3::FLOAT, 0::FLOAT), + (4::BIGINT, 4::BIGINT, 5::BIGINT, 7::FLOAT, 2::FLOAT, 3::FLOAT, 0::FLOAT, 4::FLOAT, 0::FLOAT), + (5::BIGINT, 5::BIGINT, 6::BIGINT, 7::FLOAT, 2::FLOAT, 4::FLOAT, 0::FLOAT, 5::FLOAT, 0::FLOAT) + ) AS t(id, source, target, cost, reverse_cost, x1, y1, x2, y2); + + /* the same chain with one weight for both directions */ + CREATE TEMP TABLE edges_3180_sym AS + SELECT id, source, target, cost, cost AS reverse_cost, x1, y1, x2, y2 FROM edges_3180; + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdAstar', 'pgr_dijkstra', + 'seq, node, edge, cost, agg_cost', '1::BIGINT, 6::BIGINT', + ', 0, 1::NUMERIC, 1::NUMERIC', ', 5, 1::NUMERIC, 1::NUMERIC'); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdAstarCost', 'pgr_dijkstraCost', + 'start_vid, end_vid, agg_cost', '1::BIGINT, 6::BIGINT', + ', 0, 1::NUMERIC, 1::NUMERIC', ', 5, 1::NUMERIC, 1::NUMERIC'); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdAstarCostMatrix', 'pgr_dijkstraCostMatrix', + 'start_vid, end_vid, agg_cost', 'ARRAY[1, 6]::BIGINT[]', + ', 0, 1::NUMERIC, 1::NUMERIC', ', 5, 1::NUMERIC, 1::NUMERIC'); + + /* one row per step: an edge id must not appear twice */ + RETURN QUERY SELECT is( + (SELECT count(*) - count(DISTINCT edge) FROM pgr_bdAstar( + 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges_3180', + 1::BIGINT, 6::BIGINT, false, 0, 1::NUMERIC, 1::NUMERIC) WHERE edge <> -1), + 0::BIGINT, + 'pgr_bdAstar: no edge id appears twice on the undirected route'); + + DROP TABLE edges_3180; + DROP TABLE edges_3180_sym; + +END; +$BODY$ +LANGUAGE plpgsql; + +SELECT issue_3180_tests(); + +SELECT * FROM finish(); +ROLLBACK; diff --git a/pgtap/bdDijkstra/edge_cases/issue_3180.pg b/pgtap/bdDijkstra/edge_cases/issue_3180.pg new file mode 100644 index 00000000000..9a50630050b --- /dev/null +++ b/pgtap/bdDijkstra/edge_cases/issue_3180.pg @@ -0,0 +1,120 @@ +/* :file: This file is part of the pgRouting project. +:copyright: Copyright (c) 2026-2026 pgRouting developers +:license: Creative Commons Attribution-Share Alike 3.0 https://creativecommons.org/licenses/by-sa/3.0 */ + + +/* + * Issue #3180: undirected graph where cost and reverse_cost differ + * + * On an undirected graph an edge whose cost and reverse_cost are both non + * negative and different is kept as two internal edges that share the same + * id. pgr_bdDijkstra, pgr_bdDijkstraCost and pgr_bdDijkstraCostMatrix returned a row for + * each of them, so every node and edge came back twice and agg_cost added + * both weights. The pgr_dijkstra family uses each edge once and is the + * reference here. + * + * The chain below costs 7 one way and 2 the other, so the cheapest route + * from 1 to 6 uses each edge once at cost 2: 6 rows and agg_cost 10. + */ + +BEGIN; + +SET extra_float_digits=-3; + +SELECT CASE WHEN min_version('4.1.0') THEN plan(10) ELSE plan(1) END; + +/* builds: SELECT FROM ('SELECT FROM ', , ) */ +CREATE OR REPLACE FUNCTION issue_3180_q( + fn TEXT, cols TEXT, incols TEXT, tbl TEXT, verts TEXT, flag TEXT, extra TEXT) +RETURNS TEXT AS +$BODY$ + SELECT 'SELECT ' || cols || ' FROM ' || fn || '(''SELECT ' || incols + || ' FROM ' || tbl || ''', ' || verts || ', ' || flag || extra || ')'; +$BODY$ +LANGUAGE sql IMMUTABLE; + +/* the same four checks for one function: the bug, then the two controls */ +CREATE OR REPLACE FUNCTION issue_3180_variant( + fn TEXT, ref TEXT, cols TEXT, verts TEXT, h0 TEXT, h5 TEXT) +RETURNS SETOF TEXT AS +$BODY$ +DECLARE + inc TEXT := 'id, source, target, cost, reverse_cost'; + rinc TEXT := 'id, source, target, cost, reverse_cost'; +BEGIN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h0), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected must match ' || ref || ' (agg_cost 10)'); + + IF h5 IS NOT NULL THEN + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'false', h5), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'false', ''), + fn || ': undirected with heuristic 5 must match ' || ref || ' (agg_cost 10)'); + END IF; + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180', verts, 'true', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180', verts, 'true', ''), + fn || ': control, directed matches ' || ref || ' (agg_cost 35)'); + + RETURN QUERY SELECT set_eq( + issue_3180_q(fn, cols, inc, 'edges_3180_sym', verts, 'false', ''), + issue_3180_q(ref, cols, rinc, 'edges_3180_sym', verts, 'false', ''), + fn || ': control, cost = reverse_cost matches ' || ref || ' (agg_cost 35)'); +END; +$BODY$ +LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION issue_3180_tests() +RETURNS SETOF TEXT AS +$BODY$ +BEGIN + + IF NOT min_version('4.1.0') THEN + RETURN QUERY SELECT skip(1, 'pgr_bdDijkstra: Fix implemented on 4.1.0'); + RETURN; + END IF; + + CREATE TEMP TABLE edges_3180 AS + SELECT * FROM (VALUES + (1::BIGINT, 1::BIGINT, 2::BIGINT, 7::FLOAT, 2::FLOAT), + (2::BIGINT, 2::BIGINT, 3::BIGINT, 7::FLOAT, 2::FLOAT), + (3::BIGINT, 3::BIGINT, 4::BIGINT, 7::FLOAT, 2::FLOAT), + (4::BIGINT, 4::BIGINT, 5::BIGINT, 7::FLOAT, 2::FLOAT), + (5::BIGINT, 5::BIGINT, 6::BIGINT, 7::FLOAT, 2::FLOAT) + ) AS t(id, source, target, cost, reverse_cost); + + /* the same chain with one weight for both directions */ + CREATE TEMP TABLE edges_3180_sym AS + SELECT id, source, target, cost, cost AS reverse_cost FROM edges_3180; + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdDijkstra', 'pgr_dijkstra', + 'seq, node, edge, cost, agg_cost', '1::BIGINT, 6::BIGINT', '', NULL); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdDijkstraCost', 'pgr_dijkstraCost', + 'start_vid, end_vid, agg_cost', '1::BIGINT, 6::BIGINT', '', NULL); + + RETURN QUERY SELECT * FROM issue_3180_variant('pgr_bdDijkstraCostMatrix', 'pgr_dijkstraCostMatrix', + 'start_vid, end_vid, agg_cost', 'ARRAY[1, 6]::BIGINT[]', '', NULL); + + /* one row per step: an edge id must not appear twice */ + RETURN QUERY SELECT is( + (SELECT count(*) - count(DISTINCT edge) FROM pgr_bdDijkstra( + 'SELECT id, source, target, cost, reverse_cost FROM edges_3180', + 1::BIGINT, 6::BIGINT, false) WHERE edge <> -1), + 0::BIGINT, + 'pgr_bdDijkstra: no edge id appears twice on the undirected route'); + + DROP TABLE edges_3180; + DROP TABLE edges_3180_sym; + +END; +$BODY$ +LANGUAGE plpgsql; + +SELECT issue_3180_tests(); + +SELECT * FROM finish(); +ROLLBACK;