diff --git a/Algorithms/GreedyColoringLimitedMaxColor.cpp b/Algorithms/GreedyColoringLimitedMaxColor.cpp index 53507f2..d838ec0 100644 --- a/Algorithms/GreedyColoringLimitedMaxColor.cpp +++ b/Algorithms/GreedyColoringLimitedMaxColor.cpp @@ -23,7 +23,7 @@ int GreedyColoringLimitedMaxColor::color() { for (int v : order) { std::vector forbiddenColors(boost::num_vertices(GraphInstance), -1); forbiddenColors[0] = v; - ForEachNeighbor(GraphInstance, v, [&](int n) { + ForEachNeighbor(GraphInstance, v, [&](const int n) { int c = boost::get(vertex_color, GraphInstance, n); if (c > 0)forbiddenColors[c] = v; }); diff --git a/Algorithms/GreedyColoringSimpleGraph.cpp b/Algorithms/GreedyColoringSimpleGraph.cpp index 228669d..221bd87 100644 --- a/Algorithms/GreedyColoringSimpleGraph.cpp +++ b/Algorithms/GreedyColoringSimpleGraph.cpp @@ -10,8 +10,7 @@ * @return the number of colors */ int GreedyColoringSimpleGraph::color() { - vector &order = V_c; - for (int v : order) { + for (vector &order = V_c; int v : order) { // Since vertex numbering starts at zero, we initialize forbiddenColors with the (non-existing) vertex -1 std::vector forbiddenColors(boost::num_vertices(GraphInstance), -1); forbiddenColors[0] = v; @@ -19,9 +18,9 @@ int GreedyColoringSimpleGraph::color() { int c = boost::get(vertex_color, GraphInstance, n); if (c > 0) forbiddenColors[c] = v; }); - //Find first color which can be assigned to v - auto result = find_if(forbiddenColors.begin(), forbiddenColors.end(), [&](int i) { return i != v; }); - auto res_color = distance(forbiddenColors.begin(), result); + //Find the first color which can be assigned to v + const auto result = std::ranges::find_if(forbiddenColors, [&](int i) { return i != v; }); + const auto res_color = distance(forbiddenColors.begin(), result); SetVertexColor(GraphInstance, v, res_color); } return NumOfColors(); diff --git a/Algorithms/ISet.hpp b/Algorithms/ISet.hpp index beac472..f7b01e1 100644 --- a/Algorithms/ISet.hpp +++ b/Algorithms/ISet.hpp @@ -118,19 +118,12 @@ class ISet : public IndependentSet { //Get distance-1 neighbors graph_traits::adjacency_iterator n_1, n_1_end; - for (tie(n_1, n_1_end) = adjacent_vertices(v_c, G_b); n_1 != n_1_end; n_1++) { - + for (tie(n_1, n_1_end) = adjacent_vertices(v_c, G_b); n_1 != n_1_end; ++n_1) { bool is_deleted = false; - //E_1 -> E_2 //Emulate reverse_iterator because of erase-operation - for (list::edge_iterator>::iterator e = - E_1.begin(); - e != E_1.end(); - ++e) { - + for (auto e = E_1.begin();e != E_1.end();++e) { if (source(**e, G_b) == *n_1 || target(**e, G_b) == *n_1) { - //Delete adjacent vertices if (!is_deleted) { V_r.erase(find(V_r.begin(), V_r.end(), *n_1)); @@ -145,11 +138,7 @@ class ISet : public IndependentSet { //E_3 -> E_4 //Emulate reverse_iterator because of erase-operation - for (list::edge_iterator>::iterator e = - E_3.begin(); - e != E_3.end(); - ++e) { - + for (auto e = E_3.begin();e != E_3.end();++e) { if (source(**e, G_b) == *n_1 || target(**e, G_b) == *n_1) { E_4.push_back(*e); e = E_3.erase(e); @@ -158,7 +147,7 @@ class ISet : public IndependentSet { } } - V_c.erase(find(V_c.begin(), V_c.end(), v_c)); + V_c.erase(std::ranges::find(V_c, v_c)); } } diff --git a/Algorithms/ISetRestricted.hpp b/Algorithms/ISetRestricted.hpp index 834a817..755a3bf 100644 --- a/Algorithms/ISetRestricted.hpp +++ b/Algorithms/ISetRestricted.hpp @@ -9,13 +9,13 @@ class ISetRestricted : public IndependentSet{ public: using IndependentSet::IndependentSet; - vector compute() { + vector compute() override + { vector IS; list ::edge_iterator> E_1; list ::edge_iterator> E_2; list ::edge_iterator> E_3; list ::edge_iterator> E_4; - int NumVertices_V_r = V_r.size(); int NumVertices = V_r.size() + V_c.size(); double rho = mode / 2; if (rho == 0) rho = 1.5; @@ -87,20 +87,16 @@ class ISetRestricted : public IndependentSet{ //Get distance-1 neighbors graph_traits::adjacency_iterator n_1, n_1_end; - for (tie(n_1, n_1_end) = adjacent_vertices(v_r, G_b); n_1 != n_1_end; n_1++) { + for (tie(n_1, n_1_end) = adjacent_vertices(v_r, G_b); n_1 != n_1_end; ++n_1) { bool is_deleted = false; //E_1 -> E_3 //Emulate reverse_iterator because of erase-operation - for (list::edge_iterator>::iterator e = E_1.begin(); - e != E_1.end(); - ++e) { - + for (auto e = E_1.begin();e != E_1.end();++e) { if (source(**e, G_b) == *n_1 || target(**e, G_b) == *n_1) { - if (!is_deleted) { - V_c.erase(find(V_c.begin(), V_c.end(), *n_1)); + V_c.erase(std::ranges::find(V_c, *n_1)); is_deleted = true; } @@ -112,9 +108,7 @@ class ISetRestricted : public IndependentSet{ //E_2 -> E_4 //Emulate reverse_iterator because of erase-operation - for (list::edge_iterator>::iterator e = E_2.begin(); - e != E_2.end(); - ++e) { + for (auto e = E_2.begin();e != E_2.end();++e) { if (source(**e, G_b) == *n_1 || target(**e, G_b) == *n_1) { E_4.push_back(*e); @@ -123,7 +117,7 @@ class ISetRestricted : public IndependentSet{ } } } - V_r.erase(find(V_r.begin(), V_r.end(), v_r)); + V_r.erase(std::ranges::find(V_r, v_r)); } else { @@ -131,10 +125,8 @@ class ISetRestricted : public IndependentSet{ //Get distance-1 neighbors graph_traits::adjacency_iterator n_1, n_1_end; - for (tie(n_1, n_1_end) = adjacent_vertices(v_c, G_b); n_1 != n_1_end; n_1++) { - + for (tie(n_1, n_1_end) = adjacent_vertices(v_c, G_b); n_1 != n_1_end; ++n_1) { bool is_deleted = false; - //E_1 -> E_2 //Emulate reverse_iterator because of erase-operation for (auto e = E_1.begin();e != E_1.end();++e) { @@ -143,7 +135,7 @@ class ISetRestricted : public IndependentSet{ //Delete adjacent vertices if (!is_deleted) { - V_r.erase(find(V_r.begin(), V_r.end(), *n_1)); + V_r.erase(std::ranges::find(V_r, *n_1)); is_deleted = true; } @@ -155,10 +147,7 @@ class ISetRestricted : public IndependentSet{ //E_3 -> E_4 //Emulate reverse_iterator because of erase-operation - for (list::edge_iterator>::iterator e = E_3.begin(); - e != E_3.end(); - ++e) { - + for (auto e = E_3.begin();e != E_3.end();++e) { if (source(**e, G_b) == *n_1 || target(**e, G_b) == *n_1) { E_4.push_back(*e); e = E_3.erase(e); @@ -167,18 +156,18 @@ class ISetRestricted : public IndependentSet{ } } - V_c.erase(find(V_c.begin(), V_c.end(), v_c)); + V_c.erase(std::ranges::find(V_c, v_c)); } } if (!V_r.empty()) { - for (vector::iterator v_r = V_r.begin(); v_r != V_r.end(); ++v_r) { + for (auto v_r = V_r.begin(); v_r != V_r.end(); ++v_r) { IS.push_back(*v_r); } } if (!V_c.empty()) { - for (vector::iterator v_c = V_c.begin(); v_c != V_c.end(); ++v_c) { + for (auto v_c = V_c.begin(); v_c != V_c.end(); ++v_c) { IS.push_back(*v_c); } } diff --git a/Algorithms/OneSidedD2ColorNonReqDiag.h b/Algorithms/OneSidedD2ColorNonReqDiag.h index 6a722c8..6348488 100644 --- a/Algorithms/OneSidedD2ColorNonReqDiag.h +++ b/Algorithms/OneSidedD2ColorNonReqDiag.h @@ -39,7 +39,7 @@ class OneSidedD2ColorNonReqDiag : public ColoringAlgorithms { N_2 = neighbors::Distance2NeighborsRestricted(GraphInstance, v); forbiddenColors[0] = v; //Iterate over distance-2 neighbors - for_each(N_2.begin(), N_2.end(), [&](unsigned int n_2) { + std::ranges::for_each(N_2, [&](unsigned int n_2) { //Mark colors which are used by distance-2 neighbors in forbiddenColors if (get(vertex_color, GraphInstance, n_2) > 0) { forbiddenColors[get(vertex_color, GraphInstance, n_2)] = v; @@ -47,8 +47,8 @@ class OneSidedD2ColorNonReqDiag : public ColoringAlgorithms { }); //Find the first color which can be assigned to v - auto result = find_if(forbiddenColors.begin(), forbiddenColors.end(), - bind(not_equal_to(), v, std::placeholders::_1)); + auto result = std::ranges::find_if(forbiddenColors, + bind(not_equal_to(), v, std::placeholders::_1)); int col1 = distance(forbiddenColors.begin(), result); /////////////////////////////////////////////////////////////////////////////////////// diff --git a/Algorithms/OneSidedD2ColoringNonReq.h b/Algorithms/OneSidedD2ColoringNonReq.h index ab1097e..6fccd6b 100644 --- a/Algorithms/OneSidedD2ColoringNonReq.h +++ b/Algorithms/OneSidedD2ColoringNonReq.h @@ -29,8 +29,8 @@ class OneSidedD2ColoringNonReq : public ColoringAlgorithms { vector N_2; vector forbiddenColors(NumOfVertices(GraphInstance), -1); //All edges in E_S have edge_weight=1; otherwise edge_weight=0 - //Iterate over all vertices which should be colored - for_each(V.begin(), V.end(), [&](unsigned int v) { + //Iterate over all vertices that should be colored + std::ranges::for_each(V, [&](unsigned int v) { if (get(vertex_color, GraphInstance, v) == 0) { forbiddenColors[0] = v; if (neighbors::IncidentToReqEdge(GraphInstance, v)) { @@ -44,9 +44,9 @@ class OneSidedD2ColoringNonReq : public ColoringAlgorithms { } }); - //Find first color which can be assigned to v - vector::iterator result = find_if(forbiddenColors.begin(), forbiddenColors.end(), - std::bind(std::not_equal_to(), v, std::placeholders::_1)); + //Find the first color which can be assigned to v + auto result = std::ranges::find_if(forbiddenColors, + std::bind(std::not_equal_to(), v, std::placeholders::_1)); //Color v SetVertexColor(GraphInstance, v, distance(forbiddenColors.begin(), result)); diff --git a/Algorithms/OneSidedD2ColoringNonReqBalanced.h b/Algorithms/OneSidedD2ColoringNonReqBalanced.h index 5a06288..2516014 100644 --- a/Algorithms/OneSidedD2ColoringNonReqBalanced.h +++ b/Algorithms/OneSidedD2ColoringNonReqBalanced.h @@ -48,19 +48,16 @@ class OneSidedD2ColoringNonReqBalanced : public ColoringAlgorithms { }); //Find the first color which can be assigned to v - vector::iterator result = find_if(forbiddenColors.begin(), - forbiddenColors.end(), - std::bind(std::not_equal_to(), v, std::placeholders::_1)); + const auto result = std::ranges::find_if(forbiddenColors, + std::bind(std::not_equal_to(), v, std::placeholders::_1)); //Color v SetVertexColor(GraphInstance, v, distance(forbiddenColors.begin(), result)); -// put(color, v, distance(forbiddenColors.begin(), result)); - ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// vector non_neighbours; - for_each(V_c.begin(), V_c.end(), [&](Ver vc) { - if (find(N_2.begin(), N_2.end(), vc) == N_2.end()) + std::ranges::for_each(V_c, [&](Ver vc) { + if (std::ranges::find(N_2, vc) == N_2.end()) if(get(vertex_color, GraphInstance, vc) == 0) non_neighbours.push_back(vc); }); @@ -71,7 +68,7 @@ class OneSidedD2ColoringNonReqBalanced : public ColoringAlgorithms { //map from the positions to number of that nonrequired map pos_num; //Iterate over distance-2 neighbors - for_each(non_neighbours.begin(), non_neighbours.end(), [&](unsigned int nn) { + std::ranges::for_each(non_neighbours, [&](unsigned int nn) { int cnt_nreq_det = 0; //Mark colors which are used by distance-2 neighbors in forbiddenColors for_each(adjacent_vertices(nn, GraphInstance).first, adjacent_vertices(nn, GraphInstance).second, @@ -102,12 +99,11 @@ class OneSidedD2ColoringNonReqBalanced : public ColoringAlgorithms { }); int cnt = 0; - for_each(pos_num.begin(), pos_num.end(), [&](auto map_elem) { + std::ranges::for_each(pos_num, [&](auto map_elem) { if (cnt <= std::any_cast(CustomParameters["alpha"])) { if (map_elem.second == min_nreq_det) { cnt++; SetVertexColor(GraphInstance,map_elem.first, distance(forbiddenColors.begin(), result)); -// put(color, map_elem.first, distance(forbiddenColors.begin(), result)); } } }); @@ -117,12 +113,12 @@ class OneSidedD2ColoringNonReqBalanced : public ColoringAlgorithms { int min_pos = -1; int max_req = 0; int max_pos = -1; - for_each(pos_num.begin(), pos_num.end(), [&](auto map_elem) { + std::ranges::for_each(pos_num, [&](auto map_elem) { if (map_elem.second == max_nreq_det) { int cnt_req = 0; for_each(adjacent_vertices(map_elem.first, GraphInstance).first, adjacent_vertices(map_elem.first, GraphInstance).second, - [&](Ver adj_) { + [&](const Ver adj_) { if (get(edge_weight, GraphInstance, edge(map_elem.first, adj_, GraphInstance).first) == 1) { cnt_req++; } @@ -160,4 +156,4 @@ class OneSidedD2ColoringNonReqBalanced : public ColoringAlgorithms { }; -#endif //PRECOL_ONESIDEDD2COLORING_H +#endif //PRECOL_D2ColorNonReqBalanced diff --git a/Algorithms/exact_coloring.h b/Algorithms/exact_coloring.h index 4a63768..6e21f2c 100644 --- a/Algorithms/exact_coloring.h +++ b/Algorithms/exact_coloring.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -38,14 +39,13 @@ static void gen_ind_set(Graph g,Lambda func) { static int alpha(dynbit X, set F) { int cnt = 0; - for_each(F.begin(),F.end(),[&X,&cnt](dynbit db) { - dynbit tmp = db & X; - if(tmp.none()) cnt++; + ranges::for_each(F,[&X,&cnt](const dynbit& db) { + if(const dynbit tmp = db & X; tmp.none()) cnt++; }); return cnt; } -//F is actually the all independent set +//F is actually the all-independent set static int c_k(set F, Graph g, int k) { int cnt = 0; power_set(NumOfVertices(g), [&](dynbit vi) { diff --git a/Algorithms/kClique.hpp b/Algorithms/kClique.hpp index 8b50c5a..047eca0 100644 --- a/Algorithms/kClique.hpp +++ b/Algorithms/kClique.hpp @@ -17,16 +17,15 @@ bool step(const Graph& G_c, vector& prev_vertices, int level) { - graph_traits::adjacency_iterator ai, ai_ptr, ai_lt_vtx, ai_end; + graph_traits::adjacency_iterator ai, ai_end; tie(ai, ai_end) = adjacent_vertices(Vertex, G_c); - ai_lt_vtx = ai; - for (vector::iterator pv = prev_vertices.begin(); + graph_traits::adjacency_iterator ai_lt_vtx = ai; + for (auto pv = prev_vertices.begin(); pv != prev_vertices.end(); ++pv) { - bool exists = 0; - - for (ai_ptr = ai; ai_ptr != ai_end; ++ai_ptr) { + bool exists = false; + for (graph_traits::adjacency_iterator ai_ptr = ai; ai_ptr != ai_end; ++ai_ptr) { // all adjacent vertices are ordered ascending // for next step we need only larger vertices than Vertex @@ -40,9 +39,7 @@ bool step(const Graph& G_c, } } if (!exists) { -// copy(prev_vertices.begin(), prev_vertices.end(),ostream_iterator(cout, " ")); -// cout << " " << Vertex << endl; - return 0; + return false; } } if (level == 1) { diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e86f4..b22b750 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -#cmake_minimum_required(VERSION 4.0) +cmake_minimum_required(VERSION 3.5) project(precol) set (CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) diff --git a/Graph/MatrixMarket.cpp b/Graph/MatrixMarket.cpp index 291313c..2b7b2de 100644 --- a/Graph/MatrixMarket.cpp +++ b/Graph/MatrixMarket.cpp @@ -5,7 +5,7 @@ #include "MatrixMarket.hpp" /** - * \brief Constructor for making matrix from list of edges + * \brief Constructor for making matrix from a list of edges * * @param mat list of edges * @param m the number of rows @@ -123,14 +123,14 @@ MatrixMarket::MatrixMarket(Graph &G_b, string tag, int m, int n, bool bipartite) /** * \brief Write the matrix into the file with format mtx * - * @param filename the name of file + * @param filename the name of a file * @return true if it works correctly */ bool MatrixMarket::writeToFile(char *filename) { const int size = nz; if(val.size() == 0) { double val[size]; - std::fill(val, val + size, 1); + std::fill_n(val, size, 1); mm_write_mtx_crd(filename, M, N, nz, &I[0], &J[0], val, matcode); } else { mm_write_mtx_crd(filename, M, N, nz, &I[0], &J[0], &val[0], matcode); @@ -167,12 +167,12 @@ MatrixMarket::MatrixMarket(const char *filename) { exit(1); } - /* find out size of sparse matrix .... */ + /* find out the size of sparse matrix … */ if ((ret_code = mm_read_mtx_crd_size(file, &M, &N, &nz)) != 0) exit(1); - /* reseve memory for matrices */ + /* reserve memory for matrices */ I = vector(nz); J = vector(nz); @@ -354,12 +354,11 @@ bool MatrixMarket::MtXToColumnGainGraph(Graph& CGG, const boost::numeric::ublas: } } - sort(begin(edges), end(edges), - [&](std::tuple t1, std::tuple t2) { return get<2>(t1) > get<2>(t2); }); + std::ranges::sort(edges, + [&](const std::tuple& t1, const std::tuple& t2) { return get<2>(t1) > get<2>(t2); }); for (int i = NumOfEdgesToBeRemoved; i < edges.size(); i++) { auto[v1, v2, w] = edges[i]; add_edge(v1, v2, w, CGG); } -// std::cerr << "num of edges: " << g.num_e() << std::endl; - return 0; + return false; } \ No newline at end of file diff --git a/Main/InputFile b/Main/InputFile index 0104528..1bb8ad1 100644 --- a/Main/InputFile +++ b/Main/InputFile @@ -18,7 +18,7 @@ MATRIX = ExampleMatrices/FloridaSparseMatrixCollection/ex33.mtx COLORING_ALGORITHM = D2RestrictedColumns COLORING_ORDERING = LargestFirstOrderingDegrees -### SPARSIFIFCATION +### SPECIFICATION KIND_OF_SPARSIFICATION = BlockDiagonal BLOCK_SIZE = 30 diff --git a/Orderings/LargestFirstOrderingDegrees.h b/Orderings/LargestFirstOrderingDegrees.h index ba1bf8a..247da2a 100644 --- a/Orderings/LargestFirstOrderingDegrees.h +++ b/Orderings/LargestFirstOrderingDegrees.h @@ -15,10 +15,11 @@ * A specific preordering for the coloring */ class LargestFirstOrderingDegrees : public Ordering { - bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) { + bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) override + { list> VertexDegree; //Compute Distance2Neighbors-degree for all vertices in V - for (vector::iterator v = V.begin(); v != V.end(); ++v) { + for (auto v = V.begin(); v != V.end(); ++v) { VertexDegree.push_back(pair(*v, neighbors::Distance2NeighborsRestricted(G_b, *v).size())); } //Sort after degree diff --git a/Orderings/SLO.h b/Orderings/SLO.h index b2a50ff..b1a27da 100644 --- a/Orderings/SLO.h +++ b/Orderings/SLO.h @@ -14,13 +14,14 @@ * A specific preordering for the coloring */ class SLO : public Ordering { - bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) { + bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) override + { if (restricted) return order_restricted(G_b, V); vector > VertexDegree; vector Ordering; //Compute Distance2Neighbors-degree for all vertices in v - for (vector::iterator v = V.begin(); v != V.end(); ++v) { + for (auto v = V.begin(); v != V.end(); ++v) { VertexDegree.push_back(make_pair(*v, neighbors::Distance2NeighborsRestricted(G_b, *v).size())); } @@ -28,25 +29,21 @@ class SLO : public Ordering { for (unsigned int i = 0; i < V.size(); ++i) { //find vertex with lowest Distance2Neighbors-degree - vector >::iterator v = - min_element(VertexDegree.begin(), VertexDegree.end(), lt_degree); + auto v = std::ranges::min_element(VertexDegree, lt_degree); // int minElement = (*v).first; - (*v).second = NumOfEdges(G_b); + v->second = NumOfEdges(G_b); //Add vertex to Ordering - // Ordering.insert(Ordering.begin(),(*v).first); -> + // .insert(Ordering.begin(),(*v).first); -> Ordering.push_back((*v).first); // VertexDegree.erase(minPair); //decrement degree of D_2-neighbors vector neighbors = neighbors::Distance2NeighborsRestricted(G_b, (*v).first); - for (vector::iterator n_2 = neighbors.begin(); - n_2 != neighbors.end(); - ++n_2) { - + for (auto n_2 = neighbors.begin();n_2 != neighbors.end();++n_2) { //Get the correct element of Degrees for n_2 if (*n_2 >= V.size()) { if (VertexDegree[*n_2 - V.size()].second != -1) { @@ -59,9 +56,6 @@ class SLO : public Ordering { } } - if (i % 100 == 0) { -// cout << "i= " << i << endl; - } // vector neighbors = neighbors::Distance2Neighbors(GraphInstance, (*v).first); // for (list >::iterator i = VertexDegree.begin(); @@ -74,7 +68,7 @@ class SLO : public Ordering { // } } - reverse(Ordering.begin(), Ordering.end()); + std::ranges::reverse(Ordering); V = Ordering; return EXIT_SUCCESS; @@ -85,18 +79,16 @@ class SLO : public Ordering { vector Ordering; //Compute Distance2Neighbors-degree for all vertices in v - for (vector::iterator v = V.begin(); v != V.end(); ++v) { - + for (auto v = V.begin(); v != V.end(); ++v) { VertexDegree.push_back(pair(*v, neighbors::Distance2NeighborsRestricted(G_b, *v).size())); } while (!VertexDegree.empty()) { //find vertex with lowest Distance2Neighbors-degree - list >::iterator minPair = - min_element(VertexDegree.begin(), VertexDegree.end(), lt_degree); + auto minPair = std::ranges::min_element(VertexDegree, lt_degree); - int minElement = (*minPair).first; + const int minElement = minPair->first; //Add vertex to Ordering Ordering.insert(Ordering.begin(), minElement); @@ -104,12 +96,10 @@ class SLO : public Ordering { //decrement degree of D_2-neighbors vector neighbors = neighbors::Distance2NeighborsRestricted(G_b, minElement); - for (list >::iterator i = VertexDegree.begin(); + for (auto i = VertexDegree.begin(); i != VertexDegree.end(); ++i) { - - vector::iterator n_2 = find(neighbors.begin(), neighbors.end(), (*i).first); - if (n_2 != neighbors.end()) { - (*i).second--; + if (auto n_2 = std::ranges::find(neighbors, (*i).first); n_2 != neighbors.end()) { + i->second--; } } } diff --git a/Orderings/WeightOptimumOrdering.h b/Orderings/WeightOptimumOrdering.h index 7b07dca..d9d2f98 100644 --- a/Orderings/WeightOptimumOrdering.h +++ b/Orderings/WeightOptimumOrdering.h @@ -17,7 +17,8 @@ class WeighOptimumOrdering : public Ordering { * @param restricted is the ordering IsRestrictedColoring or not? * @return */ - bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) { + bool OrderGivenVertexSubset(const Graph &G_b, vector &V, bool restricted) override + { std::vector> vertex_weight; ForEachVertexConst(G_b, [&](int v) { int sum = 0;