property-map-traits-eg.cpp 877 B

12345678910111213141516171819202122232425
  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 <iostream>
  10. #include <string>
  11. #include <boost/graph/adjacency_list.hpp>
  12. int
  13. main()
  14. {
  15. using namespace boost;
  16. typedef adjacency_list < listS, listS, directedS,
  17. property < vertex_name_t, std::string > >graph_t;
  18. graph_t g;
  19. graph_traits < graph_t >::vertex_descriptor u = add_vertex(g);
  20. property_map < graph_t, vertex_name_t >::type
  21. name_map = get(vertex_name, g);
  22. name_map[u] = "Joe";
  23. std::cout << name_map[u] << std::endl;
  24. return EXIT_SUCCESS;
  25. }