min_degree_empty.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //=======================================================================
  2. // Copyright 2017 Felix Salfelder
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //=======================================================================
  8. #include <boost/graph/minimum_degree_ordering.hpp>
  9. #include <boost/graph/adjacency_list.hpp>
  10. #include <boost/property_map/property_map.hpp>
  11. #include <boost/test/minimal.hpp>
  12. #include <boost/typeof/typeof.hpp>
  13. #include <vector>
  14. #include <map>
  15. typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> G;
  16. int test_main(int argc, char** argv)
  17. {
  18. size_t n = 10;
  19. G g(n);
  20. std::vector<int> inverse_perm(n, 0);
  21. std::vector<int> supernode_sizes(n, 1);
  22. BOOST_AUTO(id, boost::get(boost::vertex_index, g));
  23. std::vector<int> degree(n, 0);
  24. std::map<int,int> io;
  25. std::map<int,int> o;
  26. boost::minimum_degree_ordering(
  27. g
  28. , boost::make_iterator_property_map(degree.begin(), id, degree[0])
  29. , boost::make_assoc_property_map(io)
  30. , boost::make_assoc_property_map(o)
  31. , boost::make_iterator_property_map(
  32. supernode_sizes.begin()
  33. , id
  34. , supernode_sizes[0]
  35. )
  36. , 0
  37. , id
  38. );
  39. for (int k = 0; k < n; ++k)
  40. {
  41. BOOST_CHECK(o[io[k]] == k);
  42. }
  43. return 0;
  44. }