24 #ifndef INCLUDE_COLORING_PGR_SEQUENTIALVERTEXCOLORING_HPP_
25 #define INCLUDE_COLORING_PGR_SEQUENTIALVERTEXCOLORING_HPP_
29 #include <boost/property_map/property_map.hpp>
30 #include <boost/graph/graph_traits.hpp>
31 #include <boost/property_map/vector_property_map.hpp>
32 #include <boost/type_traits.hpp>
33 #include <boost/graph/adjacency_list.hpp>
34 #include <boost/graph/sequential_vertex_coloring.hpp>
62 typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS >
Graph;
82 std::vector < pgr_vertex_color_rt > results;
84 auto i_map = boost::get(boost::vertex_index, graph.graph);
87 std::vector < vertices_size_type > colors(boost::num_vertices(graph.graph));
90 auto color_map = boost::make_iterator_property_map(colors.begin(), i_map);
93 CHECK_FOR_INTERRUPTS();
96 boost::sequential_vertex_coloring(graph.graph, color_map);
97 }
catch (boost::exception
const& ex) {
100 }
catch (std::exception &e) {
125 std::vector < vertices_size_type > &colors,
127 std::vector < pgr_vertex_color_rt > results;
129 typename boost::graph_traits < Graph > ::vertex_iterator v, vend;
131 for (boost::tie(v, vend) = vertices(graph.graph); v != vend; ++v) {
132 int64_t node = graph[*v].id;
133 auto color = colors[*v];
134 results.push_back({ node,
static_cast<int64_t
>(color + 1) });
138 std::sort(results.begin(), results.end(),
140 return row1.node < row2.node;
149 #endif // INCLUDE_COLORING_PGR_SEQUENTIALVERTEXCOLORING_HPP_