-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder.hpp
42 lines (32 loc) · 1.13 KB
/
order.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef ORDER_HPP_
#define ORDER_HPP_
#include "types.hpp"
enum order_heur {
O_WEIGHTED_MIN_FILL,
O_MIN_FILL,
O_MIN_INDUCED_WIDTH,
O_MIN_DEGREE,
O_RANDOM
};
enum tie_heur {
T_UNIQUENESS,
T_RANDOM
};
#include <limits> // std::numeric_limits
template <typename T>
struct compare_vec {
compare_vec(std::vector<T> const &vec) : vec(vec) {};
bool operator()(size_t const &x, size_t const &y) {
if constexpr (std::is_integral_v<T>) {
return vec[x] < vec[y];
} else if (std::is_floating_point_v<T>) {
return vec[x] < vec[y] - std::numeric_limits<weight>::epsilon();
}
}
std::vector<T> vec;
};
std::vector<size_t> greedy_order(std::vector<std::vector<weight>> const &adj, int order_heur = O_WEIGHTED_MIN_FILL, int tie_heur = T_UNIQUENESS);
size_t induced_width(std::vector<std::vector<weight>> const &adj, std::vector<size_t> const &order);
std::vector<size_t> read_pseudotree_order(const char *filename, std::vector<size_t> const &domains);
void export_order(std::vector<size_t> const &order, std::vector<size_t> const &domains, const char *output);
#endif