50#include <lal/detail/identity_arrangement.hpp>
51#include <lal/detail/graphs/utils.hpp>
52#include <lal/detail/data_array.hpp>
54#define DECIDED_C_GT (upper_bound + 1)
89template <
bool dec
ide_upper_bound,
class graph_t, linarr_type arr_type>
93 unsigned char *
const __restrict__ bn,
94 uint64_t *
const __restrict__ L1,
99 const uint64_t n = g.get_num_nodes();
105 for (
position pu = 0; pu < n - 1; ++pu) {
113 detail::get_bool_neighbours<graph_t>(g, u, bn);
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>
163uint64_t
n_C_ladder(
const graph_t& g,
const arrangement_t& arr)
166 const uint64_t n = g.get_num_nodes();
169 assert(arr.m_arr.size() == 0 or arr.m_arr.size() == n);
172 if (n < 4) {
return 0; }
179 return ladder::compute<false>
180 (g, arr, boolean_neighborhood.
begin(), L1.
begin(), 0);
193template <
class graph_t>
195(
const graph_t& g,
const std::vector<linear_arrangement>& arrs)
198 const uint64_t n = g.get_num_nodes();
200 std::vector<uint64_t> cs(arrs.size(), 0);
201 if (n < 4) {
return cs; }
209 for (std::size_t i = 0; i < arrs.size(); ++i) {
212 assert(arrs[i].size() == n);
216 cs[i] = ladder::compute<false>
219 boolean_neighborhood.
fill(0);
242template <
class graph_t,
class arrangement_t>
245 const arrangement_t& arr,
250 const uint64_t n = g.get_num_nodes();
253 assert(arr.m_arr.size() == 0 or arr.m_arr.size() == n);
256 if (n < 4) {
return 0; }
264 ladder::compute<true>
265 (g, arr, boolean_neighborhood.
begin(), L1.
begin(), upper_bound);
280template <
class graph_t>
283 const std::vector<linear_arrangement>& arrs,
288 const uint64_t n = g.get_num_nodes();
290 std::vector<uint64_t> cs(arrs.size(), 0);
291 if (n < 4) {
return cs; }
299 for (std::size_t i = 0; i < arrs.size(); ++i) {
302 assert(arrs[i].size() == n);
306 cs[i] = ladder::compute<true>
308 boolean_neighborhood.
begin(), L1.
begin(), upper_bound);
310 for (uint64_t z = 0; z < n; ++z) {
312 boolean_neighborhood[z] = 0;
330template <
class graph_t>
333 const std::vector<linear_arrangement>& arrs,
334 const std::vector<uint64_t>& upper_bounds
340 assert(arrs.size() == upper_bounds.size());
343 const uint64_t n = g.get_num_nodes();
345 std::vector<uint64_t> cs(arrs.size(), 0);
346 if (n < 4) {
return cs; }
354 for (std::size_t i = 0; i < arrs.size(); ++i) {
357 assert(arrs[i].size() == n);
361 boolean_neighborhood.
fill(0);
363 cs[i] = ladder::compute<true>
365 boolean_neighborhood.
begin(), L1.
begin(), upper_bounds[i]);
367 for (uint64_t z = 0; z < n; ++z) {
369 boolean_neighborhood[z] = 0;
uint64_t compute(const graph_t &g, const linarr_wrapper< arr_type > &arr, unsigned char *const __restrict__ bn, uint64_t *const __restrict__ L1, uint64_t upper_bound) noexcept
Ladder computation of for undirected graphs.
Definition: C_ladder.hpp:90
uint64_t is_n_C_ladder_lesseq_than(const graph_t &g, const arrangement_t &arr, uint64_t upper_bound) noexcept
Ladder computation of with early termination.
Definition: C_ladder.hpp:243
uint64_t n_C_ladder(const graph_t &g, const arrangement_t &arr) noexcept
Ladder computation of .
Definition: C_ladder.hpp:163
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
Wrapper of a C array for autmatic deallocation of memory.
Definition: data_array.hpp:59
void fill(const T &v) noexcept
Assign the same value to every element in the data.
Definition: data_array.hpp:263
T * begin() noexcept
Non-constant raw pointer to first element.
Definition: data_array.hpp:291
A wrapper to easily use identity arrangements.
Definition: identity_arrangement.hpp:72
Typesafe position type.
Definition: basic_types.hpp:168