bfs_cc.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //=======================================================================
  2. // Copyright 2002 Indiana University.
  3. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //=======================================================================
  9. #include <boost/concept_archetype.hpp>
  10. #include <boost/graph/breadth_first_search.hpp>
  11. #include <boost/graph/graph_archetypes.hpp>
  12. int main()
  13. {
  14. using namespace boost;
  15. typedef default_constructible_archetype<
  16. sgi_assignable_archetype<
  17. equality_comparable_archetype<> > > vertex_t;
  18. {
  19. typedef incidence_graph_archetype<vertex_t, directed_tag,
  20. allow_parallel_edge_tag> IncidenceGraph;
  21. typedef vertex_list_graph_archetype<vertex_t, directed_tag,
  22. allow_parallel_edge_tag, IncidenceGraph> graph_t;
  23. graph_t& g = static_object<graph_t>::get();
  24. vertex_t s;
  25. read_write_property_map_archetype<vertex_t, color_value_archetype> color;
  26. breadth_first_search(g, s, color_map(color));
  27. }
  28. {
  29. typedef incidence_graph_archetype<vertex_t, directed_tag,
  30. allow_parallel_edge_tag> IncidenceGraph;
  31. typedef vertex_list_graph_archetype<vertex_t, directed_tag,
  32. allow_parallel_edge_tag, IncidenceGraph> graph_t;
  33. graph_t& g = static_object<graph_t>::get();
  34. vertex_t s;
  35. readable_property_map_archetype<vertex_t, std::size_t> v_index;
  36. breadth_first_search(g, s, vertex_index_map(v_index));
  37. }
  38. {
  39. typedef incidence_graph_archetype<vertex_t, undirected_tag,
  40. allow_parallel_edge_tag> IncidenceGraph;
  41. typedef vertex_list_graph_archetype<vertex_t, undirected_tag,
  42. allow_parallel_edge_tag, IncidenceGraph> Graph;
  43. typedef property_graph_archetype<Graph, vertex_index_t, std::size_t>
  44. graph_t;
  45. graph_t& g = static_object<graph_t>::get();
  46. vertex_t s;
  47. bfs_visitor<> v;
  48. buffer_archetype<vertex_t> b;
  49. breadth_first_search(g, s, visitor(v).buffer(b));
  50. }
  51. return 0;
  52. }