51#include <lal/basic_types.hpp>
52#include <lal/detail/array.hpp>
157 m_n = dir_arr.size();
167 :
m_memory(std::move(arr.m_memory)),
174 arr.m_direct =
nullptr;
175 arr.m_inverse =
nullptr;
186 arr.m_direct =
nullptr;
187 arr.m_inverse =
nullptr;
206#if !defined __LAL_SWIG_PYTHON
216 template <
typename It>
218 return from_direct(begin, end, std::distance(begin, end));
231 template <
typename It>
249#if !defined __LAL_SWIG_PYTHON
259 template <
typename It>
263 static_cast<std::size_t
>(std::distance(begin, end))
277 template <
typename It>
287 if (
size() != arr.size()) {
return size() < arr.
size(); }
289 for (std::size_t i = 0; i <
size() - 1; ++i) {
290 if (
m_direct[i] != arr.m_direct[i]) {
291 return m_direct[i] < arr.m_direct[i];
371 typename NODE,
typename POSITION,
373 (std::is_integral_v<NODE> or std::is_same_v<NODE, node_t>)
375 (std::is_integral_v<POSITION> or std::is_same_v<POSITION, position_t>)
379 void assign(
const NODE u,
const POSITION p)
noexcept {
384 if constexpr (std::is_same_v<NODE, node_t> and std::is_same_v<POSITION, position_t>) {
388 else if constexpr (std::is_same_v<NODE, node_t>) {
392 else if constexpr (std::is_same_v<POSITION, position_t>) {
419 std::is_same_v<what, node_t> or std::is_same_v<what, position_t>
423 void swap(
const what u_t,
const what v_t)
noexcept {
424 if constexpr (std::is_same_v<what, node_t>) {
485 std::size_t
size() const noexcept {
return m_n; }
508 for (std::size_t i = 0; i <
m_n; ++i) {
assign(i,i); }
530 for (
node u = 0; u <
m_n; ++u) {
583 template <
bool from_direct_arr,
typename It>
591 if constexpr (from_direct_arr) {
592 for (It it = begin; it != end; ++it, ++i) {
598 for (It it = begin; it != end; ++it, ++i) {
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103
std::vector< position > direct_as_vector() const noexcept
Constructs a std::vector from the direct arrangement.
Definition linear_arrangement.hpp:554
std::size_t m_n
Size of the arrangement (number of nodes in the arrangement).
Definition linear_arrangement.hpp:610
void swap(const what u_t, const what v_t) noexcept
Swaps the position of two vertices or of two positions.
Definition linear_arrangement.hpp:423
node * m_inverse
Pointer to the inverse arrangement values.
Definition linear_arrangement.hpp:615
position get_position_of(const node u) const noexcept
Returns the position of node u.
Definition linear_arrangement.hpp:335
void clear() noexcept
Frees the memory used by the linear arrangement.
Definition linear_arrangement.hpp:320
void mirror() noexcept
Mirror the arrangement.
Definition linear_arrangement.hpp:478
void from_data(const It begin, const It end) noexcept
Initializes this arrangement from a direct or inverse arrangement.
Definition linear_arrangement.hpp:584
std::vector< node > inverse_as_vector() const noexcept
Constructs a std::vector from the inverse arrangement.
Definition linear_arrangement.hpp:558
std::size_t size() const noexcept
Size of the arrangement (number of nodes in the arrangement).
Definition linear_arrangement.hpp:485
linear_arrangement & operator=(const linear_arrangement &arr) noexcept
Copy assignment operator.
Definition linear_arrangement.hpp:146
linear_arrangement(linear_arrangement &&arr) noexcept
Move constructor.
Definition linear_arrangement.hpp:166
static linear_arrangement from_inverse(const std::vector< node > &v) noexcept
Construct a linear arrangement from an inverse arrangement.
Definition linear_arrangement.hpp:245
void assign(const NODE u, const POSITION p) noexcept
Assigns a node u to position p.
Definition linear_arrangement.hpp:379
static linear_arrangement identity(std::size_t n) noexcept
Constructs an identity linear arrangement.
Definition linear_arrangement.hpp:494
const node * begin_direct() const noexcept
Pointer to beginning of direct arrangement.
Definition linear_arrangement.hpp:538
detail::array< uint64_t > m_memory
Definition linear_arrangement.hpp:608
linear_arrangement(const std::vector< position > &dir_arr) noexcept
Constructor with direct arrangement.
Definition linear_arrangement.hpp:128
static linear_arrangement from_inverse(It begin, It end) noexcept
Construct a linear arrangement from an inverse arrangement.
Definition linear_arrangement.hpp:260
void update_inverse() noexcept
Updates the inverse arrangement using the direct arrangement.
Definition linear_arrangement.hpp:529
void resize(std::size_t n) noexcept
Changes the size of the arrangement.
Definition linear_arrangement.hpp:355
position operator[](const node_t &u) const noexcept
Returns the position of node u.
Definition linear_arrangement.hpp:305
static linear_arrangement from_direct(It begin, It end) noexcept
Construct a linear arrangement from a direct arrangement.
Definition linear_arrangement.hpp:217
static linear_arrangement from_direct(const std::vector< position > &v) noexcept
Construct a linear arrangement from a direct arrangement.
Definition linear_arrangement.hpp:202
void shift_right() noexcept
Shifts the vertices one position to the right.
Definition linear_arrangement.hpp:459
node * end_inverse() noexcept
Pointer to end of inverse arrangement.
Definition linear_arrangement.hpp:549
node get_node_at(const position p) const noexcept
Returns the node at position p.
Definition linear_arrangement.hpp:346
static linear_arrangement from_direct(It begin, It end, std::size_t size) noexcept
Construct a linear arrangement from a direct arrangement.
Definition linear_arrangement.hpp:232
void identity() noexcept
Makes this arrangement an identity arrangement.
Definition linear_arrangement.hpp:507
virtual ~linear_arrangement() noexcept=default
Default destructor.
const node * begin_inverse() const noexcept
Pointer to beginning of inverse arrangement.
Definition linear_arrangement.hpp:547
bool operator<(const linear_arrangement &arr) const noexcept
Lexicographic comparison of two linear arrangements.
Definition linear_arrangement.hpp:286
linear_arrangement(const linear_arrangement &arr) noexcept
Copy constructor.
Definition linear_arrangement.hpp:139
node * begin_inverse() noexcept
Pointer to beginning of inverse arrangement.
Definition linear_arrangement.hpp:545
linear_arrangement() noexcept=default
Default constructor.
static linear_arrangement from_inverse(It begin, It end, std::size_t size) noexcept
Construct a linear arrangement from an inverse arrangement.
Definition linear_arrangement.hpp:278
const node * end_inverse() const noexcept
Pointer to end of inverse arrangement.
Definition linear_arrangement.hpp:551
void shift_left() noexcept
Shifts the vertices one position to the left.
Definition linear_arrangement.hpp:444
void set_pointers() noexcept
Sets m_direct and m_inverse appropriately.
Definition linear_arrangement.hpp:569
position * m_direct
Pointer to the direct arrangement values.
Definition linear_arrangement.hpp:613
node * begin_direct() noexcept
Pointer to beginning of direct arrangement.
Definition linear_arrangement.hpp:536
const node * end_direct() const noexcept
Pointer to end of direct arrangement.
Definition linear_arrangement.hpp:542
void update_direct() noexcept
Updates the direct arrangement using the inverse arrangement.
Definition linear_arrangement.hpp:517
node * end_direct() noexcept
Pointer to end of direct arrangement.
Definition linear_arrangement.hpp:540
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
T * begin() noexcept
Non-constant raw pointer to first element.
Definition array.hpp:300
std::size_t size() const noexcept
Size of the array.
Definition array.hpp:215
void resize(const std::size_t new_size) noexcept
Resize the array.
Definition array.hpp:187
void clear() noexcept
Clear the contents of the array.
Definition array.hpp:174
Typesafe node type.
Definition basic_types.hpp:70
Typesafe position type.
Definition basic_types.hpp:244