From 9216962acdc4e2064cd27c2c046ea5c9e9b94a7d Mon Sep 17 00:00:00 2001 From: Vicky Vergara Date: Mon, 12 Jul 2021 10:08:37 -0500 Subject: [PATCH] Revert " GSoC-2021 Week5: pgr_edgeColoring" --- .github/workflows/update.yml | 24 --------- include/coloring/pgr_edgeColoring.hpp | 27 +++++----- src/coloring/edgeColoring_driver.cpp | 12 +++-- src/coloring/pgr_edgeColoring.cpp | 74 ++++++++++++--------------- src/version/_version.h | 35 ------------- 5 files changed, 53 insertions(+), 119 deletions(-) delete mode 100644 src/version/_version.h diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 5fd039bfb9..253b91def0 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -16,15 +16,7 @@ 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 @@ -105,15 +97,7 @@ 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___ @@ -129,14 +113,6 @@ 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 c53d4d9294..0f58289fd0 100644 --- a/include/coloring/pgr_edgeColoring.hpp +++ b/include/coloring/pgr_edgeColoring.hpp @@ -30,11 +30,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include +#include +#include #include #include -#include "c_types/pgr_edge_t.h" -#include "c_types/pgr_vertex_color_rt.h" +#include "cpp_common/basic_edge.h" +#include "cpp_common/basic_vertex.h" #include "cpp_common/pgr_assert.h" #include "cpp_common/pgr_messages.h" @@ -42,22 +44,23 @@ 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; -public: + std::vector edgeColoring(EdgeColoring_Graph&); - std::vector edgeColoring(); + void insert_edges(EdgeColoring_Graph&, pgr_edge_t*, size_t); - Pgr_edgeColoring(pgr_edge_t*, size_t); +#if 0 Pgr_edgeColoring() = delete; +#endif #if 0 #if Boost_VERSION_MACRO >= 106800 @@ -65,13 +68,7 @@ class Pgr_edgeColoring : public Pgr_messages { #endif #endif -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: + 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 ff2e6417dc..3c7c19e790 100644 --- a/src/coloring/edgeColoring_driver.cpp +++ b/src/coloring/edgeColoring_driver.cpp @@ -28,11 +28,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "drivers/coloring/edgeColoring_driver.h" +#include +#include +#include #include -#include "coloring/pgr_edgeColoring.hpp" - #include "c_types/graph_enum.h" +#include "coloring/pgr_edgeColoring.hpp" #include "cpp_common/pgr_alloc.hpp" #include "cpp_common/pgr_assert.h" @@ -64,9 +66,11 @@ void do_pgr_edgeColoring( graphType gType = UNDIRECTED; pgrouting::functions::Pgr_edgeColoring::EdgeColoring_Graph undigraph(gType); - pgrouting::functions::Pgr_edgeColoring fn_edgeColoring {data_edges, total_edges}; + pgrouting::functions::Pgr_edgeColoring fn_edgeColoring; + + fn_edgeColoring.insert_edges(undigraph, data_edges, total_edges); - results = fn_edgeColoring.edgeColoring(); + results = fn_edgeColoring.edgeColoring(undigraph); auto count = results.size(); diff --git a/src/coloring/pgr_edgeColoring.cpp b/src/coloring/pgr_edgeColoring.cpp index 61ffb07be2..7f30f00af4 100644 --- a/src/coloring/pgr_edgeColoring.cpp +++ b/src/coloring/pgr_edgeColoring.cpp @@ -26,29 +26,53 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -#include "coloring/pgr_edgeColoring.hpp" +#include #include #include +#include +#include +#include #include +#include + +#include "drivers/coloring/edgeColoring_driver.h" +#include "coloring/pgr_edgeColoring.hpp" -#include "cpp_common/identifiers.hpp" +#include "cpp_common/pgr_alloc.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() { +Pgr_edgeColoring::edgeColoring(EdgeColoring_Graph &graph) { 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, boost::get(boost::edge_bundle, graph)); + boost::edge_coloring(graph, color_map); } catch (boost::exception const &ex) { (void)ex; throw; @@ -60,48 +84,16 @@ Pgr_edgeColoring::edgeColoring() { } for (auto e_i : boost::make_iterator_range(boost::edges(graph))) { - auto edge = E_to_id[e_i]; - int64_t color = graph[e_i]; + int64_t edge = E_to_id[e_i]; + int64_t color = colors[edge]; results.push_back({edge, (color + 1)}); } return results; } -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)); - } +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); } } // namespace functions diff --git a/src/version/_version.h b/src/version/_version.h deleted file mode 100644 index 394d307c82..0000000000 --- a/src/version/_version.h +++ /dev/null @@ -1,35 +0,0 @@ -/*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)"; -