LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
dependency_flux.hpp
1/*********************************************************************
2 *
3 * Linear Arrangement Library - A library that implements a collection
4 * algorithms for linear arrangments of graphs.
5 *
6 * Copyright (C) 2019 - 2024
7 *
8 * This file is part of Linear Arrangement Library. The full code is available
9 * at:
10 * https://github.com/LAL-project/linear-arrangement-library.git
11 *
12 * Linear Arrangement Library is free software: you can redistribute it
13 * and/or modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * Linear Arrangement Library is distributed in the hope that it will be
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with Linear Arrangement Library. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * Contact:
26 *
27 * LluĂ­s Alemany Puig (lluis.alemany.puig@upc.edu)
28 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
29 * CQL (Complexity and Quantitative Linguistics Lab)
30 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
31 * Webpage: https://cqllab.upc.edu/people/lalemany/
32 *
33 * Ramon Ferrer i Cancho (rferrericancho@cs.upc.edu)
34 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office 220, Omega building
37 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
38 * Webpage: https://cqllab.upc.edu/people/rferrericancho/
39 *
40 ********************************************************************/
41
42#pragma once
43
44// lal includes
45#include <lal/linear_arrangement.hpp>
46#include <lal/numeric/rational.hpp>
47#include <lal/graphs/rooted_tree.hpp>
48#include <lal/graphs/free_tree.hpp>
49
50namespace lal {
51namespace linarr {
52
59public:
60
61 // GETTERS
62
64 [[nodiscard]] uint64_t get_left_span() const noexcept { return m_left_span;; }
66 [[nodiscard]] uint64_t get_right_span() const noexcept { return m_right_span; }
68 [[nodiscard]] uint64_t get_size() const noexcept { return m_dependencies.size(); }
70 [[nodiscard]] uint64_t get_weight() const noexcept { return m_weight; }
71
73 [[nodiscard]] uint64_t& get_left_span() noexcept { return m_left_span;; }
75 [[nodiscard]] uint64_t& get_right_span() noexcept { return m_right_span; }
77 [[nodiscard]] uint64_t& get_weight() noexcept { return m_weight; }
78
80 [[nodiscard]] const std::vector<edge>& get_dependencies() const noexcept
81 { return m_dependencies; }
82
90 [[nodiscard]] numeric::rational get_RL_ratio_rational() const noexcept
99 [[nodiscard]] double get_RL_ratio() const noexcept
100 { return get_RL_ratio_rational().to_double(); }
101
109 [[nodiscard]] numeric::rational get_WS_ratio_rational() const noexcept
110 { return numeric::rational(m_weight, m_dependencies.size()); }
118 [[nodiscard]] double get_WS_ratio() const noexcept
119 { return get_WS_ratio_rational().to_double(); }
120
121 // SETTERS
122
124 void set_left_span(const uint64_t ls) noexcept { m_left_span = ls; }
126 void set_right_span(const uint64_t rs) noexcept { m_right_span = rs; }
128 void set_weight(const uint64_t w) noexcept { m_weight = w; }
129
131 void set_dependencies(const std::vector<edge>& deps) noexcept
132 { m_dependencies = deps; }
133
135 void set_dependencies(std::vector<edge>&& deps) noexcept
136 { m_dependencies = std::move(deps); }
137
138private:
141 uint64_t m_left_span = 0;
144 uint64_t m_right_span = 0;
150 std::vector<edge> m_dependencies;
157 uint64_t m_weight = 0;
158};
159
160} // -- namespace linarr
161} // -- namespace lal
Dependency flux.
Definition dependency_flux.hpp:58
double get_WS_ratio() const noexcept
Returns the W/S ratio.
Definition dependency_flux.hpp:118
void set_dependencies(const std::vector< edge > &deps) noexcept
Sets the set of dependencies.
Definition dependency_flux.hpp:131
uint64_t m_right_span
Definition dependency_flux.hpp:144
void set_dependencies(std::vector< edge > &&deps) noexcept
Sets the set of dependencies.
Definition dependency_flux.hpp:135
uint64_t & get_left_span() noexcept
Returns a reference to the left span of this flux.
Definition dependency_flux.hpp:73
numeric::rational get_RL_ratio_rational() const noexcept
Returns the R/L ratio.
Definition dependency_flux.hpp:90
uint64_t m_left_span
Definition dependency_flux.hpp:141
double get_RL_ratio() const noexcept
Returns the R/L ratio.
Definition dependency_flux.hpp:99
uint64_t get_weight() const noexcept
Returns weight of this flux.
Definition dependency_flux.hpp:70
void set_left_span(const uint64_t ls) noexcept
Sets the left span.
Definition dependency_flux.hpp:124
uint64_t get_left_span() const noexcept
Returns left span of this flux.
Definition dependency_flux.hpp:64
uint64_t m_weight
Weight of this flux.
Definition dependency_flux.hpp:157
numeric::rational get_WS_ratio_rational() const noexcept
Returns the W/S ratio.
Definition dependency_flux.hpp:109
uint64_t get_size() const noexcept
Returns the size of this flux.
Definition dependency_flux.hpp:68
const std::vector< edge > & get_dependencies() const noexcept
Returns the set of dependencies.
Definition dependency_flux.hpp:80
uint64_t get_right_span() const noexcept
Returns right span of this flux.
Definition dependency_flux.hpp:66
std::vector< edge > m_dependencies
Dependencies in this flux.
Definition dependency_flux.hpp:150
uint64_t & get_weight() noexcept
Returns a reference to the weight of this flux.
Definition dependency_flux.hpp:77
void set_right_span(const uint64_t rs) noexcept
Sets the right span.
Definition dependency_flux.hpp:126
void set_weight(const uint64_t w) noexcept
Sets the weight.
Definition dependency_flux.hpp:128
uint64_t & get_right_span() noexcept
Returns a reference to the right span of this flux.
Definition dependency_flux.hpp:75
Exact rational number.
Definition rational.hpp:63
double to_double() const noexcept
Converts this rational to a double-precision floating-point value.
Definition rational.hpp:853
Main namespace of the library.
Definition basic_types.hpp:48