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
24 changes: 24 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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___
Expand All @@ -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
27 changes: 15 additions & 12 deletions include/coloring/pgr_edgeColoring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,48 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>

#include <iostream>
#include <limits>
#include <map>
#include <vector>

#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"

namespace pgrouting {
namespace functions {

class Pgr_edgeColoring : public Pgr_messages {
public:
public:
using EdgeColoring_Graph =
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, pgrouting::Basic_vertex, size_t,
pgrouting::Basic_edge>;
boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::no_property,
size_t, boost::no_property>;

using V = boost::graph_traits<EdgeColoring_Graph>::vertex_descriptor;
using E = boost::graph_traits<EdgeColoring_Graph>::edge_descriptor;
using V_it = boost::graph_traits<EdgeColoring_Graph>::vertex_iterator;
using E_it = boost::graph_traits<EdgeColoring_Graph>::edge_iterator;

std::vector<pgr_vertex_color_rt> edgeColoring(EdgeColoring_Graph&);
public:

void insert_edges(EdgeColoring_Graph&, pgr_edge_t*, size_t);
std::vector<pgr_vertex_color_rt> edgeColoring();

#if 0
Pgr_edgeColoring(pgr_edge_t*, size_t);
Pgr_edgeColoring() = delete;
#endif

#if 0
#if Boost_VERSION_MACRO >= 106800
friend std::ostream& operator<<(std::ostream &, const Pgr_edgeColoring&);
#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<int64_t, V> id_to_V;
std::map<V, int64_t> V_to_id;
Expand Down
12 changes: 4 additions & 8 deletions src/coloring/edgeColoring_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "drivers/coloring/edgeColoring_driver.h"

#include <algorithm>
#include <sstream>
#include <string>
#include <vector>

#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"

Expand Down Expand Up @@ -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();

Expand Down
74 changes: 41 additions & 33 deletions src/coloring/pgr_edgeColoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,29 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#include <boost/graph/adjacency_list.hpp>
#include "coloring/pgr_edgeColoring.hpp"
#include <boost/graph/edge_coloring.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/iteration_macros.hpp>

#include <sstream>
#include <string>
#include <vector>
#include <algorithm>

#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<boost::vecS, boost::vecS, boost::undirectedS, pgrouting::Basic_vertex, size_t,
pgrouting::Basic_edge>
EdgeColoring_Graph;
typedef typename boost::graph_traits<EdgeColoring_Graph>::vertex_descriptor V;
typedef typename boost::graph_traits<EdgeColoring_Graph>::edge_descriptor E;
typedef typename boost::graph_traits<EdgeColoring_Graph>::vertex_iterator V_it;
typedef typename boost::graph_traits<EdgeColoring_Graph>::edge_iterator E_it;

} // namespace

namespace pgrouting {
namespace functions {

std::vector<pgr_vertex_color_rt>
Pgr_edgeColoring::edgeColoring(EdgeColoring_Graph &graph) {
Pgr_edgeColoring::edgeColoring() {
std::vector<pgr_vertex_color_rt> results;

auto i_map = boost::get(boost::edge_bundle, graph);

std::vector<size_t> 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;
Expand All @@ -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<int64_t> 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
Expand Down
35 changes: 35 additions & 0 deletions src/version/_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*PGR-GNU*****************************************************************

File: _version.h.in

Function's developer:
Copyright (c) 2015 Celia Virginia Vergara Castillo
Mail: [email protected]

------

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)";