diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 253b91def0..5fd039bfb9 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -16,7 +16,15 @@ jobs: strategy: fail-fast: false matrix: +<<<<<<< HEAD +<<<<<<< HEAD old_pgr: [3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.2.0] +======= + old_pgr: [3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1, 3.1.2, 3.1.3] +>>>>>>> origin/main +======= + old_pgr: [3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.2.0] +>>>>>>> 9509fa40c40867ba9a153c61ad09a91f4da342e0 steps: - uses: actions/checkout@v2 @@ -97,7 +105,15 @@ jobs: - name: Test old version after update run: | sudo service postgresql start +<<<<<<< HEAD +<<<<<<< HEAD + sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.3.0';" +======= + sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.2.0';" +>>>>>>> origin/main +======= sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.3.0';" +>>>>>>> 9509fa40c40867ba9a153c61ad09a91f4da342e0 sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "SELECT * FROM pgr_full_version();" sudo -u postgres bash ./tools/testers/pg_prove_tests.sh postgres 5432 sudo -u postgres dropdb -p 5432 ___pgr___test___ @@ -113,6 +129,14 @@ jobs: - name: Test old version with new lib after update run: | +<<<<<<< HEAD +<<<<<<< HEAD + sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.3.0';" +======= + sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.2.0';" +>>>>>>> origin/main +======= sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "ALTER EXTENSION pgrouting UPDATE TO '3.3.0';" +>>>>>>> 9509fa40c40867ba9a153c61ad09a91f4da342e0 sudo -u postgres psql -p 5432 -d ___pgr___test___ -c "SELECT * FROM pgr_full_version();" sudo -u postgres bash ./tools/testers/pg_prove_tests.sh postgres 5432 diff --git a/include/coloring/pgr_edgeColoring.hpp b/include/coloring/pgr_edgeColoring.hpp index 0f58289fd0..c53d4d9294 100644 --- a/include/coloring/pgr_edgeColoring.hpp +++ b/include/coloring/pgr_edgeColoring.hpp @@ -30,13 +30,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include -#include -#include #include #include -#include "cpp_common/basic_edge.h" -#include "cpp_common/basic_vertex.h" +#include "c_types/pgr_edge_t.h" +#include "c_types/pgr_vertex_color_rt.h" #include "cpp_common/pgr_assert.h" #include "cpp_common/pgr_messages.h" @@ -44,23 +42,22 @@ namespace pgrouting { namespace functions { class Pgr_edgeColoring : public Pgr_messages { - public: +public: using EdgeColoring_Graph = - boost::adjacency_list; + boost::adjacency_list; using V = boost::graph_traits::vertex_descriptor; using E = boost::graph_traits::edge_descriptor; using V_it = boost::graph_traits::vertex_iterator; using E_it = boost::graph_traits::edge_iterator; - std::vector edgeColoring(EdgeColoring_Graph&); +public: - void insert_edges(EdgeColoring_Graph&, pgr_edge_t*, size_t); + std::vector edgeColoring(); -#if 0 + Pgr_edgeColoring(pgr_edge_t*, size_t); Pgr_edgeColoring() = delete; -#endif #if 0 #if Boost_VERSION_MACRO >= 106800 @@ -68,7 +65,13 @@ class Pgr_edgeColoring : public Pgr_messages { #endif #endif - private: +private: + V get_boost_vertex(int64_t id) const; + int64_t get_vertex_id(V v) const; + int64_t get_edge_id(E e) const; + + +private: EdgeColoring_Graph graph; std::map id_to_V; std::map V_to_id; diff --git a/src/coloring/edgeColoring_driver.cpp b/src/coloring/edgeColoring_driver.cpp index 3c7c19e790..ff2e6417dc 100644 --- a/src/coloring/edgeColoring_driver.cpp +++ b/src/coloring/edgeColoring_driver.cpp @@ -28,13 +28,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/coloring/edgeColoring_driver.h" -#include -#include -#include #include -#include "c_types/graph_enum.h" #include "coloring/pgr_edgeColoring.hpp" + +#include "c_types/graph_enum.h" #include "cpp_common/pgr_alloc.hpp" #include "cpp_common/pgr_assert.h" @@ -66,11 +64,9 @@ void do_pgr_edgeColoring( graphType gType = UNDIRECTED; pgrouting::functions::Pgr_edgeColoring::EdgeColoring_Graph undigraph(gType); - pgrouting::functions::Pgr_edgeColoring fn_edgeColoring; - - fn_edgeColoring.insert_edges(undigraph, data_edges, total_edges); + pgrouting::functions::Pgr_edgeColoring fn_edgeColoring {data_edges, total_edges}; - results = fn_edgeColoring.edgeColoring(undigraph); + results = fn_edgeColoring.edgeColoring(); auto count = results.size(); diff --git a/src/coloring/pgr_edgeColoring.cpp b/src/coloring/pgr_edgeColoring.cpp index 7f30f00af4..61ffb07be2 100644 --- a/src/coloring/pgr_edgeColoring.cpp +++ b/src/coloring/pgr_edgeColoring.cpp @@ -26,53 +26,29 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -#include +#include "coloring/pgr_edgeColoring.hpp" #include #include -#include -#include -#include #include -#include - -#include "drivers/coloring/edgeColoring_driver.h" -#include "coloring/pgr_edgeColoring.hpp" -#include "cpp_common/pgr_alloc.hpp" +#include "cpp_common/identifiers.hpp" #include "cpp_common/pgr_assert.h" -namespace { - -typedef typename boost::adjacency_list - EdgeColoring_Graph; -typedef typename boost::graph_traits::vertex_descriptor V; -typedef typename boost::graph_traits::edge_descriptor E; -typedef typename boost::graph_traits::vertex_iterator V_it; -typedef typename boost::graph_traits::edge_iterator E_it; - -} // namespace namespace pgrouting { namespace functions { std::vector -Pgr_edgeColoring::edgeColoring(EdgeColoring_Graph &graph) { +Pgr_edgeColoring::edgeColoring() { std::vector results; - auto i_map = boost::get(boost::edge_bundle, graph); - - std::vector colors(boost::num_edges(graph)); - - auto color_map = boost::make_iterator_property_map(colors.begin(), i_map); - #if 0 CHECK_FOR_INTERRUPTS(); #endif try { - boost::edge_coloring(graph, color_map); + boost::edge_coloring(graph, boost::get(boost::edge_bundle, graph)); } catch (boost::exception const &ex) { (void)ex; throw; @@ -84,16 +60,48 @@ Pgr_edgeColoring::edgeColoring(EdgeColoring_Graph &graph) { } for (auto e_i : boost::make_iterator_range(boost::edges(graph))) { - int64_t edge = E_to_id[e_i]; - int64_t color = colors[edge]; + auto edge = E_to_id[e_i]; + int64_t color = graph[e_i]; results.push_back({edge, (color + 1)}); } return results; } -void Pgr_edgeColoring::insert_edges(EdgeColoring_Graph &graph, pgr_edge_t *edges, size_t count) { - for (size_t i = 0; i < count; i++) - add_edge(edges[i].source, edges[i].target, graph); +Pgr_edgeColoring::Pgr_edgeColoring(pgr_edge_t *edges, + size_t total_edges) { + /* + * Inserting vertices + */ + Identifiers ids; + for (size_t i = 0; i < total_edges; ++i) { + ids += edges[i].source; + ids += edges[i].target; + } + + for (const auto id : ids) { + auto v = add_vertex(graph); + id_to_V.insert(std::make_pair(id, v)); + V_to_id.insert(std::make_pair(v, id)); + } + + /* + * Inserting edges + */ + bool added; + for (size_t i = 0; i < total_edges; ++i) { + auto edge = edges[i]; + auto v1 = get_boost_vertex(edge.source); + auto v2 = get_boost_vertex(edge.target); + auto e_exists = boost::edge(v1, v2, graph); + if (e_exists.second) continue; + + if (edge.source == edge.target) continue; + + E e; + boost::tie(e, added) = boost::add_edge(v1, v2, edge.cost, graph); + + E_to_id.insert(std::make_pair(e, edge.id)); + } } } // namespace functions diff --git a/src/version/_version.h b/src/version/_version.h new file mode 100644 index 0000000000..394d307c82 --- /dev/null +++ b/src/version/_version.h @@ -0,0 +1,35 @@ +/*PGR-GNU***************************************************************** + +File: _version.h.in + +Function's developer: +Copyright (c) 2015 Celia Virginia Vergara Castillo +Mail: vicky_vergara@hotmail.com + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ********************************************************************PGR-GNU*/ + +#define BOOST_VERSION "1.74.0"; +#define CMAKE_BUILD_TYPE "Release"; +#define COMPILER_VERSION "GNU-10.3.0"; +#define COMPILATION_DATE "2021/06/30"; +#define PROJECT_GIT_HASH "aa8d57db3"; +#define PROJECT_LIB_NAME "pgrouting-3.3.0"; +#define CMAKE_SYSTEM_NAME "Linux-5.11.0-22-generic"; +#define POSTGRES_VERSION "PostgreSQL 13.3 (Ubuntu 13.3-0ubuntu0.21.04.1)"; +