int main() { // Construct an arrangement of seven intersecting line segments. Point_2 p1(1, 1), p2(1, 4), p3(2, 2), p4(3, 7), p5(4, 4), p6(7, 1), p7(9, 3); Ex_arrangement arr; insert(arr, Segment_2(p1, p6)); insert(arr, Segment_2(p1, p4)); insert(arr, Segment_2(p2, p6)); insert(arr, Segment_2(p3, p7)); insert(arr, Segment_2(p3, p5)); insert(arr, Segment_2(p6, p7)); insert(arr, Segment_2(p4, p7)); // Create a mapping of the arrangement faces to indices. Face_index_map index_map(arr); // Perform breadth-first search from the unbounded face, using the event // visitor to associate each arrangement face with its discover time. unsigned int time = 0; boost::breadth_first_search(Dual_arrangement(arr), arr.unbounded_face(), boost::vertex_index_map(index_map).visitor (boost::make_bfs_visitor (stamp_times(Face_property_map(), time, boost::on_discover_vertex())))); // Print the discover time of each arrangement face. Ex_arrangement::Face_iterator fit; for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { std::cout << "Discover time " << fit->data() << " for "; if (fit != arr.unbounded_face()) { std::cout << "face "; print_ccb<Ex_arrangement>(fit->outer_ccb()); } else std::cout << "the unbounded face." << std::endl; } return 0; }
typename property_traits<ComponentsMap>::value_type kosaraju_strong_components(Graph& G, ComponentsMap c, FinishTime finish_time, ColorMap color) { function_requires< MutableGraphConcept<Graph> >(); // ... typedef typename graph_traits<Graph>::vertex_descriptor Vertex; typedef typename property_traits<ColorMap>::value_type ColorValue; typedef color_traits<ColorValue> Color; typename property_traits<FinishTime>::value_type time = 0; depth_first_search (G, make_dfs_visitor(stamp_times(finish_time, time, on_finish_vertex())), color); Graph G_T(num_vertices(G)); transpose_graph(G, G_T); typedef typename property_traits<ComponentsMap>::value_type count_type; count_type c_count(0); detail::components_recorder<ComponentsMap> vis(c, c_count); // initialize G_T typename graph_traits<Graph>::vertex_iterator ui, ui_end; for (tie(ui, ui_end) = vertices(G_T); ui != ui_end; ++ui) put(color, *ui, Color::white()); typedef typename property_traits<FinishTime>::value_type D; typedef indirect_cmp< FinishTime, std::less<D> > Compare; Compare fl(finish_time); std::priority_queue<Vertex, std::vector<Vertex>, Compare > Q(fl); typename graph_traits<Graph>::vertex_iterator i, j, iend, jend; tie(i, iend) = vertices(G_T); tie(j, jend) = vertices(G); for ( ; i != iend; ++i, ++j) { put(finish_time, *i, get(finish_time, *j)); Q.push(*i); } while ( !Q.empty() ) { Vertex u = Q.top(); Q.pop(); if (get(color, u) == Color::white()) { depth_first_visit(G_T, u, vis, color); ++c_count; } } return c_count; }