vector_as_graph.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  9. #error The vector_as_graph.hpp header requires partial specialization
  10. #endif
  11. #include <vector>
  12. #include <list>
  13. #include <iostream> // needed by graph_utility. -Jeremy
  14. #include <boost/graph/vector_as_graph.hpp>
  15. #include <boost/graph/graph_utility.hpp>
  16. int
  17. main()
  18. {
  19. enum
  20. { r, s, t, u, v, w, x, y, N };
  21. char name[] = "rstuvwxy";
  22. typedef std::vector < std::list < int > > Graph;
  23. Graph g(N);
  24. g[r].push_back(v);
  25. g[s].push_back(r);
  26. g[s].push_back(r);
  27. g[s].push_back(w);
  28. g[t].push_back(x);
  29. g[u].push_back(t);
  30. g[w].push_back(t);
  31. g[w].push_back(x);
  32. g[x].push_back(y);
  33. g[y].push_back(u);
  34. boost::print_graph(g, name);
  35. return 0;
  36. }