50#include <lal/detail/arrangement_wrapper.hpp>
51#include <lal/detail/graphs/utils.hpp>
52#include <lal/detail/array.hpp>
54#define DECIDED_C_GT (upper_bound + 1)
88template <
bool dec
ide_upper_bound,
class graph_t,
class arrangement_t>
92 const arrangement_t& arr,
93 unsigned char *
const __restrict__ bn,
94 uint64_t *
const __restrict__ L1,
95 const uint64_t upper_bound
99 const uint64_t n = g.get_num_nodes();
105 for (
position pu = 0; pu < n - 1; ++pu) {
115 for (
position pv = pu + 1; pv < n; ++pv) {
124 C += bn[v]*(S - L1[pv]);
128 if constexpr (decide_upper_bound) {
129 if (C > upper_bound) {
162template <
class graph_t,
class arrangement_t>
164(
const graph_t& g,
const arrangement_t& arr)
167 const uint64_t n = g.get_num_nodes();
170 assert(arr.size() == 0 or arr.size() == n);
173 if (n < 4) {
return 0; }
181 (g, arr, boolean_neighborhood.
begin(), L1.
begin(), 0);
194template <
class graph_t>
196(
const graph_t& g,
const std::vector<linear_arrangement>& arrs)
199 const uint64_t n = g.get_num_nodes();
201 std::vector<uint64_t> cs(arrs.size(), 0);
202 if (n < 4) {
return cs; }
210 for (std::size_t i = 0; i < arrs.size(); ++i) {
213 assert(arrs[i].size() == n);
220 boolean_neighborhood.
fill(0);
243template <
class graph_t,
class arrangement_t>
247 const arrangement_t& arr,
248 const uint64_t upper_bound
252 const uint64_t n = g.get_num_nodes();
255 assert(arr.size() == 0 or arr.size() == n);
258 if (n < 4) {
return 0; }
267 (g, arr, boolean_neighborhood.
begin(), L1.
begin(), upper_bound);
282template <
class graph_t>
286 const std::vector<linear_arrangement>& arrs,
287 const uint64_t upper_bound
291 const uint64_t n = g.get_num_nodes();
293 std::vector<uint64_t> cs(arrs.size(), 0);
294 if (n < 4) {
return cs; }
302 for (std::size_t i = 0; i < arrs.size(); ++i) {
305 assert(arrs[i].size() == n);
311 boolean_neighborhood.
begin(), L1.
begin(), upper_bound);
313 for (uint64_t z = 0; z < n; ++z) {
315 boolean_neighborhood[z] = 0;
333template <
class graph_t>
337 const std::vector<linear_arrangement>& arrs,
338 const std::vector<uint64_t>& upper_bounds
344 assert(arrs.size() == upper_bounds.size());
347 const uint64_t n = g.get_num_nodes();
349 std::vector<uint64_t> cs(arrs.size(), 0);
350 if (n < 4) {
return cs; }
358 for (std::size_t i = 0; i < arrs.size(); ++i) {
361 assert(arrs[i].size() == n);
365 boolean_neighborhood.
fill(0);
369 boolean_neighborhood.
begin(), L1.
begin(), upper_bounds[i]);
371 for (uint64_t z = 0; z < n; ++z) {
373 boolean_neighborhood[z] = 0;
uint64_t compute(const graph_t &g, const arrangement_t &arr, unsigned char *const __restrict__ bn, uint64_t *const __restrict__ L1, const uint64_t upper_bound) noexcept
Ladder computation of for undirected graphs.
Definition ladder.hpp:90
uint64_t is_n_C_ladder_lesseq_than(const graph_t &g, const arrangement_t &arr, const uint64_t upper_bound) noexcept
Ladder computation of with early termination.
Definition ladder.hpp:245
uint64_t n_C_ladder(const graph_t &g, const arrangement_t &arr) noexcept
Ladder computation of .
Definition ladder.hpp:164
void get_bool_neighbors(const graph_t &g, const node u, char_type *const neighs) noexcept
Retrieves the neighbors of a node in an undirected graph as a list of 0-1 values.
Definition utils.hpp:73
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
Wrapper of a C array for automatic deallocation of memory.
Definition array.hpp:59
void fill(const T &v) noexcept
Assign the same value to every element in the data.
Definition array.hpp:272
T * begin() noexcept
Non-constant raw pointer to first element.
Definition array.hpp:300
Typesafe position type.
Definition basic_types.hpp:244