adj_list_ra_edgelist.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //=======================================================================
  2. // Copyright 2001 Indiana University.
  3. // Author: 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/config.hpp>
  10. #include <boost/graph/adjacency_list.hpp>
  11. #include <iostream>
  12. int
  13. main()
  14. {
  15. using namespace boost;
  16. typedef adjacency_list<vecS, vecS, bidirectionalS, no_property,
  17. property<int, edge_weight_t>, no_property, vecS> Graph;
  18. const std::size_t n = 3;
  19. typedef std::pair<std::size_t, std::size_t> E;
  20. E edge_array[] = { E(0,1), E(0,2), E(0,1) };
  21. const std::size_t m = sizeof(edge_array) / sizeof(E);
  22. Graph g(edge_array, edge_array + m, n);
  23. graph_traits<Graph>::edge_iterator edge_iterator;
  24. for (std::size_t i = 0; i < m; ++i) {
  25. const graph_traits<Graph>::edge_iterator e = edges(g).first + i;
  26. std::cout << *e << " ";
  27. }
  28. std::cout << std::endl;
  29. return 0;
  30. }