29 #include <boost/config.hpp>
30 #include <boost/graph/adjacency_list.hpp>
31 #include <boost/graph/connected_components.hpp>
32 #include <boost/graph/strong_components.hpp>
33 #include <boost/graph/biconnected_components.hpp>
44 namespace algorithms {
46 std::vector<pgr_components_rt>
50 std::vector<V> components(num_vertices(graph.
graph));
53 CHECK_FOR_INTERRUPTS();
55 num_comps = boost::connected_components(graph.
graph, &components[0]);
61 std::vector< std::vector< int64_t > > results(num_comps);
62 for (
auto vd : boost::make_iterator_range(vertices(graph.
graph))) {
63 results[components[vd]].push_back(graph[vd].
id);
70 std::vector<pgr_components_rt>
75 std::vector<V> components(num_vertices(graph.
graph));
78 CHECK_FOR_INTERRUPTS();
80 num_comps = boost::strong_components(
82 boost::make_iterator_property_map(components.begin(),
83 get(boost::vertex_index, graph.
graph)));
89 std::vector< std::vector< int64_t > > results(num_comps);
90 for (
auto vd : boost::make_iterator_range(vertices(graph.
graph))) {
91 results[components[vd]].push_back(graph[vd].
id);
100 std::vector<pgr_components_rt>
105 using Edge_map = std::map< E, size_t >;
109 boost::associative_property_map<Edge_map> bimap(bicmp_map);
112 num_comps = biconnected_components(graph.
graph, bimap);
117 std::vector< std::vector< int64_t > > results(num_comps);
118 for (
auto ed : boost::make_iterator_range(edges(graph.
graph))) {
119 results[bimap[ed]].push_back(graph[ed].
id);
131 CHECK_FOR_INTERRUPTS();
134 std::vector<V> art_points;
136 boost::articulation_points(graph.
graph, std::back_inserter(art_points));
143 for (
const auto v : art_points) {
144 results += graph[v].id;
165 using EO_i = G::EO_i;
169 std::vector<V> components(num_vertices(graph.
graph));
172 CHECK_FOR_INTERRUPTS();
174 ini_comps = boost::connected_components(graph.
graph, &components[0]);
179 CHECK_FOR_INTERRUPTS();
180 std::vector<V> art_points;
182 boost::articulation_points(graph.
graph, std::back_inserter(art_points));
187 for (
auto v : boost::make_iterator_range(vertices(graph.
graph))) {
189 art_points.push_back(v);
193 for (
const auto u : art_points) {
194 for (
const auto v : art_points) {
199 auto p = boost::edge(u, v, graph.
graph);
204 if (!p.second)
continue;
206 auto id = graph[
edge].id;
211 if (processed_edges.
has(
id))
continue;
216 processed_edges += id;
222 int parallel_count = 0;
224 boost::tie(ei, ei_end) = out_edges(u, graph.
graph);
226 for ( ; ei != ei_end; ++ei) {
227 if (target(*ei, graph.
graph) == v) ++parallel_count;
230 if (parallel_count == 1) {
236 now_comps = boost::connected_components(graph.
graph, &components[0]);
238 boost::add_edge(boost::source(
edge, graph.
graph),
245 if (now_comps > ini_comps) {