graph-property-iter-eg.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. //=======================================================================
  2. // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //=======================================================================
  8. #include <boost/config.hpp>
  9. #include <string>
  10. #include <iostream>
  11. #include <boost/graph/adjacency_list.hpp>
  12. #include <boost/graph/property_iter_range.hpp>
  13. int
  14. main()
  15. {
  16. using namespace boost;
  17. typedef adjacency_list < listS, vecS, directedS,
  18. property < vertex_name_t, std::string > >graph_t;
  19. graph_t g(3);
  20. const char *vertex_names[] = { "Kubrick", "Clark", "Hal" };
  21. int i = 0;
  22. graph_property_iter_range < graph_t, vertex_name_t >::iterator v, v_end;
  23. for (boost::tie(v, v_end) = get_property_iter_range(g, vertex_name);
  24. v != v_end; ++v, ++i)
  25. *v = vertex_names[i];
  26. boost::tie(v, v_end) = get_property_iter_range(g, vertex_name);
  27. std::copy(v, v_end, std::ostream_iterator < std::string > (std::cout, " "));
  28. std::cout << std::endl;
  29. return 0;
  30. }