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 | |
9 | #include <boost/graph/minimum_degree_ordering.hpp> |
10 | #include <boost/graph/adjacency_list.hpp> |
11 | #include <boost/property_map/property_map.hpp> |
12 | #include <boost/core/lightweight_test.hpp> |
13 | #include <boost/typeof/typeof.hpp> |
14 | #include <vector> |
15 | #include <map> |
16 | |
17 | typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS > G; |
18 | |
19 | int main(int argc, char** argv) |
20 | { |
21 | size_t n = 10; |
22 | G g(n); |
23 | |
24 | std::vector< int > inverse_perm(n, 0); |
25 | std::vector< int > supernode_sizes(n, 1); |
26 | BOOST_AUTO(id, boost::get(boost::vertex_index, g)); |
27 | std::vector< int > degree(n, 0); |
28 | std::map< int, int > io; |
29 | std::map< int, int > o; |
30 | |
31 | boost::minimum_degree_ordering(G&: g, |
32 | degree: boost::make_iterator_property_map(iter: degree.begin(), id, degree[0]), |
33 | inverse_perm: boost::make_assoc_property_map(c&: io), perm: boost::make_assoc_property_map(c&: o), |
34 | supernode_size: boost::make_iterator_property_map( |
35 | iter: supernode_sizes.begin(), id, supernode_sizes[0]), |
36 | delta: 0, vertex_index_map: id); |
37 | |
38 | for (size_t k = 0; k < n; ++k) |
39 | { |
40 | BOOST_TEST(o[io[k]] == k); |
41 | } |
42 | |
43 | return boost::report_errors(); |
44 | } |
45 | |