49#include <lal/iterators/Q_iterator.hpp>
50#include <lal/detail/data_array.hpp>
51#include <lal/detail/identity_arrangement.hpp>
53#define idx(i,j, C) ((i)*(C) + (j))
54#define DECIDED_C_GT (upper_bound + 1)
62namespace brute_force {
82template <
bool dec
ide_upper_bound, linarr_type arr_type>
86 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, linarr_type arr_type>
174 for (
position_t pw = begin; pw <= end; ++pw) {
176 const node w = arr[pw];
188 pu < pw and pw < pv and pv < pz;
190 if constexpr (decide_upper_bound) {
191 if (C > upper_bound) {
return DECIDED_C_GT; }
205 pu < pw and pw < pv and pv < pz;
207 if constexpr (decide_upper_bound) {
208 if (C > upper_bound) {
return DECIDED_C_GT; }
232template <
bool dec
ide_upper_bound, linarr_type arr_type>
243 for (
node_t u = 0ull; u < g.get_num_nodes(); ++u) {
250 if (pu >= pv) {
continue; }
254 C = inner_compute<decide_upper_bound>
255 (g, pu,pv, arr, C, upper_bound);
257 if constexpr (decide_upper_bound) {
258 if (C > upper_bound) {
return DECIDED_C_GT; }
265 if (pu >= pv) {
continue; }
269 C = inner_compute<decide_upper_bound>
270 (g, pu,pv, arr, C, upper_bound);
272 if constexpr (decide_upper_bound) {
273 if (C > upper_bound) {
return DECIDED_C_GT; }
300template <
class graph_t,
class arrangement_t>
304 const uint64_t n = g.get_num_nodes();
307 assert(arr.m_arr.size() == 0 or arr.m_arr.size() == n);
310 if (n < 4) {
return 0; }
312 return brute_force::compute<false>(g, arr, 0);
325template <
class graph_t>
327(
const graph_t& g,
const std::vector<linear_arrangement>& arrs)
330 const uint64_t n = g.get_num_nodes();
332 std::vector<uint64_t> cs(arrs.size());
335 std::fill(cs.begin(), cs.end(), 0);
340 for (std::size_t i = 0; i < arrs.size(); ++i) {
344 assert(arrs[i].size() == n);
348 cs[i] = brute_force::compute<false>(g,
nonident_arr(arrs[i]), 0);
370template <
class graph_t,
class arrangement_t>
372(
const graph_t& g,
const arrangement_t& arr, uint64_t upper_bound)
375 const uint64_t n = g.get_num_nodes();
378 assert(arr.m_arr.size() == 0 or arr.m_arr.size() == n);
381 if (n < 4) {
return 0; }
383 return brute_force::compute<true>(g, arr, upper_bound);
398template <
class graph_t>
400(
const graph_t& g,
const std::vector<linear_arrangement>& arrs, uint64_t upper_bound)
403 const uint64_t n = g.get_num_nodes();
405 std::vector<uint64_t> cs(arrs.size());
407 std::fill(cs.begin(), cs.end(), 0);
412 for (std::size_t i = 0; i < arrs.size(); ++i) {
415 assert(arrs[i].size() == n);
419 cs[i] = brute_force::compute<true>(g,
nonident_arr(arrs[i]), upper_bound);
435template <
class graph_t>
438 const std::vector<linear_arrangement>& arrs,
439 const std::vector<uint64_t>& upper_bounds
445 assert(arrs.size() == upper_bounds.size());
447 const uint64_t n = g.get_num_nodes();
449 std::vector<uint64_t> cs(arrs.size());
451 std::fill(cs.begin(), cs.end(), 0);
456 for (std::size_t i = 0; i < arrs.size(); ++i) {
459 assert(arrs[i].size() == n);
463 cs[i] = brute_force::compute<true>(g,
nonident_arr(arrs[i]), upper_bounds[i]);
Directed graph class.
Definition: directed_graph.hpp:68
uint64_t get_num_nodes() const noexcept
Returns the number of ndoes.
Definition: graph.hpp:198
Undirected graph class.
Definition: undirected_graph.hpp:67
const neighbourhood & get_neighbours(node u) const noexcept
Returns the neighbourhood of node u.
Definition: undirected_graph.hpp:315
uint64_t inner_compute(const graphs::directed_graph &g, position pu, position pv, const linarr_wrapper< arr_type > &arr, uint64_t C, uint64_t upper_bound) noexcept
Brute force computation of for directed graphs.
Definition: C_brute_force.hpp:158
uint64_t compute(const graphs::undirected_graph &g, const linarr_wrapper< arr_type > &arr, uint64_t upper_bound=0) noexcept
Brute force computation of for undirected graphs.
Definition: C_brute_force.hpp:83
uint64_t is_n_C_brute_force_lesseq_than(const graph_t &g, const arrangement_t &arr, uint64_t upper_bound) noexcept
Brute force computation of with early termination.
Definition: C_brute_force.hpp:372
uint64_t n_C_brute_force(const graph_t &g, const arrangement_t &arr) noexcept
Brute force computation of .
Definition: C_brute_force.hpp:301
linarr_wrapper< linarr_type::nonident > nonident_arr(const linear_arrangement &arr) noexcept
Shorthand for a nonidentity arrangement.
Definition: identity_arrangement.hpp:121
Main namespace of the library.
Definition: basic_types.hpp:50
uint64_t position
Node's position type.
Definition: basic_types.hpp:55
uint64_t node
Node type. See Node / Vertex page for further details.
Definition: basic_types.hpp:53
std::vector< node > neighbourhood
List of nodes.
Definition: basic_types.hpp:62
A wrapper to easily use identity arrangements.
Definition: identity_arrangement.hpp:72
Typesafe node type.
Definition: basic_types.hpp:67
Typesafe position type.
Definition: basic_types.hpp:168