51#include <lal/graphs/rooted_tree.hpp>
52#include <lal/linarr/C.hpp>
53#include <lal/iterators/E_iterator.hpp>
54#include <lal/internal/data_array.hpp>
69 if (arr.size() == 0) {
return true; }
71 internal::data_array<position> d(arr.size(), 0);
73 if (p >= arr.size()) {
return false; }
74 if (d[p] > 0) {
return false; }
93 if constexpr (std::is_base_of_v<G, graphs::tree>) {
99 if (arr.size() == 0) {
return true; }
101 if (g.get_num_nodes() != arr.size()) {
return false; }
105 const position max_pos = *std::max_element(arr.begin(), arr.end());
106 return max_pos == arr.size() - 1;
127 const uint32_t invalid = g.get_num_edges()*g.get_num_edges() + 1;
161 if (not
is_planar(rt, arr)) {
return false; }
163 if (arr.size() == 0) {
165 iterators::E_iterator e_it(rt);
166 while (not e_it.end()) {
167 const auto [s,t] = e_it.get_edge();
168 const bool r_covered_st = s < r and r < t;
169 const bool r_covered_ts = t < r and r < s;
170 if (r_covered_st or r_covered_ts) {
return false; }
177 iterators::E_iterator e_it(rt);
178 while (not e_it.end()) {
179 const auto [s,t] = e_it.get_edge();
180 const bool r_covered_st = arr[s] < arr[r] and arr[r] < arr[t];
181 const bool r_covered_ts = arr[t] < arr[r] and arr[r] < arr[s];
182 if (r_covered_st or r_covered_ts) {
return false; }
Rooted tree graph class.
Definition rooted_tree.hpp:107
node get_root() const noexcept
Return the root of this tree.
Definition rooted_tree.hpp:485
bool is_rooted_tree() const noexcept
Is this tree a valid rooted tree?
Definition rooted_tree.hpp:470
bool is_arrangement(const G &g, const linear_arrangement &arr) noexcept
Is a given arrangement valid?
Definition formal_constraints.hpp:91
bool is_permutation(const linear_arrangement &arr={}) noexcept
Is a given input arrangement a permutation?
Definition formal_constraints.hpp:68
uint32_t is_num_crossings_lesseq_than(const graphs::directed_graph &G, uint32_t upper_bound, const algorithms_C &A=algorithms_C::ladder) noexcept
Is the number of crossings in the linear arrangement less than a constant?
bool is_planar(const G &g, const linear_arrangement &arr={}) noexcept
Is a given arrangement planar?
Definition formal_constraints.hpp:122
bool is_projective(const graphs::rooted_tree &rt, const linear_arrangement &arr={}) noexcept
Is a given arrangement projective?
Definition formal_constraints.hpp:152
Main namespace of the library.
Definition definitions.hpp:48
uint32_t position
Node's position type.
Definition definitions.hpp:53
uint32_t node
Node type.
Definition definitions.hpp:51
std::vector< position > linear_arrangement
A linear arrangement of the nodes of a graph.
Definition definitions.hpp:72