void create_S(graph_t* S, graph_t* A) { std::vector<int> component(num_vertices(*A)), discover_time(num_vertices(*A)); // const int num = strong_components(*A, &component[0]); TODO: const int num = boost::strong_components(*A, boost::make_iterator_property_map(component.begin(), boost::get(boost::vertex_index, *A), component[0])); // now, create new graph for(unsigned int i=0; i<num;i++) boost::add_vertex(*S); // get the property map for vertex indices typedef property_map<graph_t, vertex_index_t>::type IndexMap; IndexMap index = get(vertex_index, *A); graph_traits<graph_t>::edge_iterator ei, ei_end; for (tie(ei, ei_end) = edges(*A); ei != ei_end; ++ei) { const int source_comp = component[index[source(*ei, *A)]]; const int target_comp = component[index[target(*ei, *A)]]; if(source_comp != target_comp) add_edge(source_comp, target_comp,*S); } assert(boyer_myrvold_planarity_test(*S)); }
std::pair<std::size_t, OutputIterator> biconnected_components(const Graph& g, ComponentMap comp, OutputIterator out, VertexIndexMap index_map) { typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type; std::vector<vertices_size_type> discover_time(num_vertices(g)); std::vector<vertices_size_type> lowpt(num_vertices(g)); vertices_size_type vst(0); return biconnected_components (g, comp, out, make_iterator_property_map(discover_time.begin(), index_map, vst), make_iterator_property_map(lowpt.begin(), index_map, vst), index_map); }