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
4 changes: 2 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:
push:
paths:
- '.github/workflows/ubuntu.yml'
- '.github/workflows/update.yml'
- 'src/**'
- 'include/**'
- 'sql/**'
Expand All @@ -23,7 +23,7 @@ on:

pull_request:
paths:
- '.github/workflows/check-queries.yml'
- '.github/workflows/update.yml'
- 'src/**'
- 'include/**'
- 'sql/**'
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To read all history of releases go to the latest [release notes](https://docs.pg
4.0.3 Bug fixes

* [#3176](https://github.com/pgRouting/pgrouting/issues/3176): Boost broken links
* [#3180](https://github.com/pgRouting/pgrouting/issues/3180): Undirected graph with cost != reverse_cost: aStar, bdAstar and
bdDijkstra functions return every node and edge twice

</details>

Expand Down
2 changes: 1 addition & 1 deletion doc/src/pgRouting-installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ be found in `Installation wiki

To use pgRouting, PostGIS needs to be installed, please read the information
about installation in this `Install Guide
<https://www.postgis.us/presentations/postgis_install_guide_22.html>`__
<https://postgis.net/documentation/getting_started/>`__

.. _install-short:

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 @@ -38,6 +38,8 @@ pgRouting 4.0.3 Release Notes
...............................................................................

* :issue:`3176`: Boost broken links
* :issue:`3180`: Undirected graph with cost != reverse_cost: aStar, bdAstar and
bdDijkstra functions return every node and edge twice

pgRouting 4.0.2 Release Notes
-------------------------------------------------------------------------------
Expand Down
48 changes: 46 additions & 2 deletions include/cpp_common/base_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,59 @@ class Pgr_base_graph {
}
}

/**
* @brief Inserts edges storing a single undirected edge between 2 vertices
*
* cost is the minof(cost and reverse_cost).
* Avoids parallel edges.
*/
template <typename T>
void insert_edges_min(const std::vector<T> &edges) {
pgassert(is_undirected());
for (const auto &edge : edges) {
if ((edge.cost < 0) && (edge.reverse_cost < 0)) continue;

auto vm_s = get_V(T_V(edge, true));
auto vm_t = get_V(T_V(edge, false));

pgassert(vertices_map.find(edge.source) != vertices_map.end());
pgassert(vertices_map.find(edge.target) != vertices_map.end());

double c = edge.cost;
double rc = edge.reverse_cost;
double best = -1.0;
if (c >= 0 && (rc < 0 || c <= rc)) best = c;
else if (rc >= 0) best = rc;

if (best < 0) continue;

E e1;
bool found = false;
boost::tie(e1, found) = boost::edge(vm_s, vm_t, graph);
if (found) {
if (best < graph[e1].cost) {
graph[e1].cost = best;
graph[e1].id = edge.id;
}
} else {
bool inserted = false;
E e;
boost::tie(e, inserted) = boost::add_edge(vm_s, vm_t, graph);
graph[e].cost = best;
graph[e].id = edge.id;
}
}
}


template <typename T> void insert_min_edges_no_parallel(const std::vector<T> &edges) {
for (const auto edge : edges) {
for (const auto &edge : edges) {
graph_add_min_edge_no_parallel(edge);
}
}

template <typename T> void insert_negative_edges(const std::vector<T> &edges, bool normal = true) {
for (const auto edge : edges) {
for (const auto &edge : edges) {
graph_add_neg_edge(edge, normal);
}
}
Expand Down
2 changes: 1 addition & 1 deletion locale/de/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6860,7 +6860,7 @@ msgstr ""
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr ""

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr ""

msgid "Short Version"
Expand Down
7 changes: 5 additions & 2 deletions 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.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-19 04:43+0000\n"
"POT-Creation-Date: 2026-11-24 20:01+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 @@ -3534,6 +3534,9 @@ msgstr ""
msgid ":issue:`3176`: Boost broken links"
msgstr ""

msgid ":issue:`3180`: Undirected graph with cost != reverse_cost: aStar, bdAstar and bdDijkstra functions return every node and edge twice"
msgstr ""

msgid "pgRouting 4.0.2 Release Notes"
msgstr ""

Expand Down Expand Up @@ -6994,7 +6997,7 @@ msgstr ""
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr ""

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr ""

msgid "Short Version"
Expand Down
4 changes: 2 additions & 2 deletions locale/es/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6865,8 +6865,8 @@ msgstr "Instalación"
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr "Las instrucciones para descargar e instalar los binarios para diferentes sistemas operativos, notas adicionales y correcciones no incluidas en esta documentación se pueden encontrar en `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgstr "Para utilizar pgRouting, PostGIS necesita ser instalado, por favor lea la información sobre la instalación en esta `Guía de Instalación <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr "Para utilizar pgRouting, PostGIS necesita ser instalado, por favor lea la información sobre la instalación en esta `Guía de Instalación <https://postgis.net/documentation/getting_started/>`__"

msgid "Short Version"
msgstr "Versión corta"
Expand Down
2 changes: 1 addition & 1 deletion locale/ja/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -7009,7 +7009,7 @@ msgstr "インストール"
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr ""

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr ""

msgid "Short Version"
Expand Down
2 changes: 1 addition & 1 deletion locale/ko/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6985,7 +6985,7 @@ msgstr "설치"
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr ""

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr ""

msgid "Short Version"
Expand Down
7 changes: 5 additions & 2 deletions 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.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-19 04:43+0000\n"
"POT-Creation-Date: 2026-11-24 20:01+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 @@ -3532,6 +3532,9 @@ msgstr ""
msgid ":issue:`3176`: Boost broken links"
msgstr ""

msgid ":issue:`3180`: Undirected graph with cost != reverse_cost: aStar, bdAstar and bdDijkstra functions return every node and edge twice"
msgstr ""

msgid "pgRouting 4.0.2 Release Notes"
msgstr ""

Expand Down Expand Up @@ -6943,7 +6946,7 @@ msgstr ""
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr ""

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr ""

msgid "Short Version"
Expand Down
4 changes: 2 additions & 2 deletions locale/sv/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6861,8 +6861,8 @@ msgstr "Installation"
msgid "Instructions for downloading and installing binaries for different operating systems, additional notes and corrections not included in this documentation can be found in `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"
msgstr "Instruktioner för nedladdning och installation av binärfiler för olika operativsystem, ytterligare anmärkningar och korrigeringar som inte ingår i denna dokumentation finns i `Installation wiki <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__"

msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgstr "För att använda pgRouting måste PostGIS vara installerat, läs informationen om installation i denna installationsguide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr "För att använda pgRouting måste PostGIS vara installerat, läs informationen om installation i denna installationsguide <https://postgis.net/documentation/getting_started/>`__"

msgid "Short Version"
msgstr "Kort version"
Expand Down
4 changes: 2 additions & 2 deletions locale/zh_Hans/LC_MESSAGES/pgrouting_doc_strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -7260,8 +7260,8 @@ msgid "Instructions for downloading and installing binaries for different operat
msgstr "有关下载和安装适用于不同操作系统的二进制文件的说明、本文档中未包含的其他注释和更正,可以在 `安装维基 <https://github.com/pgRouting/pgrouting/wiki/Notes-on-Download%2C-Installation-and-building-pgRouting>`__ 中找到"

#, fuzzy
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__"
msgstr "使用pgRouting需要安装PostGIS,请阅读本 `安装指南 <https://www.postgis.us/presentations/postgis_install_guide_22.html>`__ 中有关安装的信息"
msgid "To use pgRouting, PostGIS needs to be installed, please read the information about installation in this `Install Guide <https://postgis.net/documentation/getting_started/>`__"
msgstr "使用pgRouting需要安装PostGIS,请阅读本 `安装指南 <https://postgis.net/documentation/getting_started/>`__ 中有关安装的信息"

msgid "Short Version"
msgstr "简洁版本"
Expand Down
37 changes: 37 additions & 0 deletions pgtap/astar/aStarCostMatrix/compare_dijkstra.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* :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 */

BEGIN;

SELECT CASE WHEN min_lib_version('4.0.3') THEN plan(4) ELSE plan(1) END;

UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id;

CREATE or REPLACE FUNCTION astarCostMatrixCompareDijkstra()
RETURNS SETOF TEXT AS
$BODY$

BEGIN

IF min_lib_version('4.0.3') THEN

RETURN QUERY
SELECT * from compare_dijkstraCostMatrix('pgr_astarCostMatrix', ', x1,y1,x2,y2 ', 'edges', ',0');

ELSE

RETURN query
SELECT skip(1, 'Fix done on on version 4.0.3');

END IF;

RETURN;
END
$BODY$
language plpgsql;

SELECT * from astarCostMatrixCompareDijkstra();

SELECT * FROM finish();
ROLLBACK;
56 changes: 17 additions & 39 deletions pgtap/astar/astar/compare_dijkstra/combinations.pg
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,44 @@

BEGIN;

SELECT CASE WHEN min_version('3.2.0') THEN plan(4) ELSE plan(1) END;
SELECT CASE WHEN min_version('3.2.0') AND min_lib_version('4.0.3') THEN plan(16) WHEN min_version('3.2.0') THEN plan(4) ELSE plan(1) END;

UPDATE edges SET cost = sign(cost) + 0.001 * id * id, reverse_cost = sign(reverse_cost) + 0.001 * id * id;

CREATE or REPLACE FUNCTION astarCompareDijkstra(lim INTEGER default 17)
CREATE or REPLACE FUNCTION CompareDijkstra()
RETURNS SETOF TEXT AS
$BODY$
DECLARE
inner_sql TEXT;
dijkstra_sql TEXT;
astar_sql TEXT;
vids TEXT;
data TEXT;
BEGIN

IF NOT min_version('3.2.0') THEN
RETURN query
SELECT skip(1, 'Combinations signature added on version 3.2');
RETURN;
END IF;

data := ' path_seq, start_vid, end_vid, round(cost::numeric,8) AS cost, round(agg_cost::numeric,8) AS agg_cost ';
vids := ' SELECT * FROM combinations ';

IF min_lib_version('4.0.3') THEN

-----------------------
-- with reverse cost
-----------------------
inner_sql := 'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges';
-- DIRECTED
dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, true)';
astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, true, heuristic := 0)';
RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
RETURN QUERY
SELECT * from compare_dijkstra_combinations('pgr_astar', ', x1,y1,x2,y2 ', 'edges', ',0');
RETURN QUERY
SELECT * from compare_dijkstra_combinations('pgr_astar', ', x1,y1,x2,y2 ', 'edges_asym', ',0');
RETURN QUERY
SELECT * from compare_dijkstra_combinations('pgr_astar', ', x1,y1,x2,y2 ', 'edges_asym_w_dup_ids', ',0');
RETURN QUERY
SELECT * from compare_dijkstra_combinations('pgr_astar', ', x1,y1,x2,y2 ', 'edges_asym_w_parallels', ',0');

-- UNDIRECTED
dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, false)';
astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, false, heuristic := 0)';
RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
ELSE

-----------------------
-- NO reverse cost
-----------------------
-- DIRECTED
inner_sql := 'SELECT id, source, target, cost, x1, y1, x2, y2 FROM edges';
dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, true)';
astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, true, heuristic := 0)';
RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
RETURN QUERY
SELECT * from compare_dijkstra_combinations('pgr_astar', ', x1,y1,x2,y2 ', 'edges', ',0');

-- UNDIRECTED
dijkstra_sql := 'SELECT ' || data || ' FROM pgr_dijkstra($$' || inner_sql || '$$, $$' || vids || '$$, false)';
astar_sql := 'SELECT ' || data || ' FROM pgr_astar($$' || inner_sql || '$$, $$' || vids || '$$, false, heuristic := 0)';
RETURN query SELECT set_eq(astar_sql, dijkstra_sql, astar_sql);
END IF;

RETURN;
END
$BODY$
language plpgsql;

SELECT * from astarCompareDijkstra();

SELECT * from CompareDijkstra();

SELECT * FROM finish();
ROLLBACK;

Loading
Loading