49#include <lal/iterators/Q_iterator.hpp>
50#include <lal/detail/array.hpp>
51#include <lal/detail/arrangement_wrapper.hpp>
53#define idx(i,j, C) ((i)*(C) + (j))
54#define DECIDED_C_GT (upper_bound + 1)
61namespace brute_force {
81template <
bool dec
ide_upper_bound,
class arrangement_t>
85 const arrangement_t& arr,
86 const uint64_t upper_bound = 0
101 if (pu >= pv) {
continue; }
110 for (
position_t pw = begin; pw <= end; ++pw) {
112 const node w = arr[pw];
124 pu < pw and pw < pv and pv < pz;
126 if constexpr (decide_upper_bound) {
127 if (C > upper_bound) {
return DECIDED_C_GT; }
156template <
bool dec
ide_upper_bound,
class arrangement_t>
162 const arrangement_t& arr,
164 const uint64_t upper_bound
175 for (
position_t pw = begin; pw <= end; ++pw) {
177 const node w = arr[pw];
189 pu < pw and pw < pv and pv < pz;
191 if constexpr (decide_upper_bound) {
192 if (C > upper_bound) {
return DECIDED_C_GT; }
206 pu < pw and pw < pv and pv < pz;
208 if constexpr (decide_upper_bound) {
209 if (C > upper_bound) {
return DECIDED_C_GT; }
233template <
bool dec
ide_upper_bound,
class arrangement_t>
237 const arrangement_t& arr,
238 const uint64_t upper_bound
246 for (
node_t u = 0ull; u < g.get_num_nodes(); ++u) {
253 if (pu >= pv) {
continue; }
258 (g, pu,pv, arr, C, upper_bound);
260 if constexpr (decide_upper_bound) {
261 if (C > upper_bound) {
return DECIDED_C_GT; }
268 if (pu >= pv) {
continue; }
273 (g, pu,pv, arr, C, upper_bound);
275 if constexpr (decide_upper_bound) {
276 if (C > upper_bound) {
return DECIDED_C_GT; }
303template <
class graph_t,
class arrangement_t>
305(
const graph_t& g,
const arrangement_t& arr)
308 const uint64_t n = g.get_num_nodes();
311 assert(arr.size() == 0 or arr.size() == n);
314 if (n < 4) {
return 0; }
329template <
class graph_t>
331(
const graph_t& g,
const std::vector<linear_arrangement>& arrs)
334 const uint64_t n = g.get_num_nodes();
336 std::vector<uint64_t> cs(arrs.size());
339 std::fill(cs.begin(), cs.end(), 0);
344 for (std::size_t i = 0; i < arrs.size(); ++i) {
348 assert(arrs[i].size() == n);
374template <
class graph_t,
class arrangement_t>
376(
const graph_t& g,
const arrangement_t& arr,
const uint64_t upper_bound)
379 const uint64_t n = g.get_num_nodes();
382 assert(arr.size() == 0 or arr.size() == n);
385 if (n < 4) {
return 0; }
402template <
class graph_t>
405 const std::vector<linear_arrangement>& arrs,
406 const uint64_t upper_bound
410 const uint64_t n = g.get_num_nodes();
412 std::vector<uint64_t> cs(arrs.size());
414 std::fill(cs.begin(), cs.end(), 0);
419 for (std::size_t i = 0; i < arrs.size(); ++i) {
422 assert(arrs[i].size() == n);
442template <
class graph_t>
446 const std::vector<linear_arrangement>& arrs,
447 const std::vector<uint64_t>& upper_bounds
453 assert(arrs.size() == upper_bounds.size());
455 const uint64_t n = g.get_num_nodes();
457 std::vector<uint64_t> cs(arrs.size());
459 std::fill(cs.begin(), cs.end(), 0);
464 for (std::size_t i = 0; i < arrs.size(); ++i) {
467 assert(arrs[i].size() == n);
Directed graph class.
Definition directed_graph.hpp:67
uint64_t get_num_nodes() const noexcept
Returns the number of ndoes.
Definition graph.hpp:207
Undirected graph class.
Definition undirected_graph.hpp:66
const neighbourhood & get_neighbors(const node u) const noexcept
Returns the neighbourhood of node u.
Definition undirected_graph.hpp:372
uint64_t compute(const graphs::undirected_graph &g, const arrangement_t &arr, const uint64_t upper_bound=0) noexcept
Brute force computation of for undirected graphs.
Definition brute_force.hpp:83
uint64_t inner_compute(const graphs::directed_graph &g, const position pu, const position pv, const arrangement_t &arr, uint64_t C, const uint64_t upper_bound) noexcept
Brute force computation of for directed graphs.
Definition brute_force.hpp:158
uint64_t is_n_C_brute_force_lesseq_than(const graph_t &g, const arrangement_t &arr, const uint64_t upper_bound) noexcept
Brute force computation of with early termination.
Definition brute_force.hpp:376
uint64_t n_C_brute_force(const graph_t &g, const arrangement_t &arr) noexcept
Brute force computation of .
Definition brute_force.hpp:305
arrangement_wrapper< arrangement_type::nonidentity > nonidentity_arr(const linear_arrangement &arr) noexcept
Shorthand for a nonidentity arrangement.
Definition arrangement_wrapper.hpp:133
Main namespace of the library.
Definition basic_types.hpp:48
uint64_t position
Node's position type.
Definition basic_types.hpp:53
uint64_t node
Node type. See Node / Vertex page for further details.
Definition basic_types.hpp:51
std::vector< node > neighbourhood
List of nodes.
Definition basic_types.hpp:64
Typesafe node type.
Definition basic_types.hpp:70
Typesafe position type.
Definition basic_types.hpp:244