LAL: Linear Arrangement Library 21.07.01
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 - 2021
7 *
8 * This file is part of Linear Arrangement Library. To see the full code
9 * visit the webpage:
10 * https://github.com/lluisalemanypuig/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 (lalemany@cs.upc.edu)
28 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
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 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office S124, 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/definitions.hpp>
46#include <lal/numeric/rational.hpp>
47
48namespace lal {
49namespace linarr {
50
57public:
58
59 // GETTERS
60
62 inline uint32_t get_left_span() const noexcept { return m_left_span;; }
64 inline uint32_t get_right_span() const noexcept { return m_right_span; }
66 inline uint32_t get_size() const noexcept
67 { return static_cast<uint32_t>(m_dependencies.size()); }
69 inline uint32_t get_weight() const noexcept { return m_weight; }
70
71#ifndef SWIG
73 inline uint32_t& get_left_span() noexcept { return m_left_span;; }
75 inline uint32_t& get_right_span() noexcept { return m_right_span; }
77 inline uint32_t& get_weight() noexcept { return m_weight; }
78
80 std::vector<edge>& get_dependencies() { return m_dependencies; }
81#endif
82
84 const std::vector<edge>& get_dependencies() const noexcept
85 { return m_dependencies; }
86
103 inline double get_RL_ratio() const noexcept
104 { return get_RL_ratio_rational().to_double(); }
105
114 { return numeric::rational(m_weight, m_dependencies.size()); }
122 inline double get_WS_ratio() const noexcept
123 { return get_WS_ratio_rational().to_double(); }
124
125 // SETTERS
126
128 inline void set_left_span(uint32_t ls) noexcept { m_left_span = ls; }
130 inline void set_right_span(uint32_t rs) noexcept { m_right_span = rs; }
132 inline void set_weight(uint32_t w) noexcept { m_weight = w; }
133
135 inline void set_dependencies(const std::vector<edge>& deps) noexcept
136 { m_dependencies = deps; }
137
138#ifndef SWIG
140 inline void set_dependencies(std::vector<edge>&& deps) noexcept
141 { m_dependencies = std::move(deps); }
142#endif
143
144private:
147 uint32_t m_left_span = 0;
150 uint32_t m_right_span = 0;
156 std::vector<edge> m_dependencies;
163 uint32_t m_weight = 0;
164
165};
166
167} // -- namespace linarr
168} // -- namespace lal
Dependency flux.
Definition dependency_flux.hpp:56
uint32_t & get_left_span() noexcept
Returns a reference to the left span of this flux.
Definition dependency_flux.hpp:73
double get_WS_ratio() const noexcept
Returns the W/S ratio.
Definition dependency_flux.hpp:122
void set_dependencies(const std::vector< edge > &deps) noexcept
Sets the set of dependencies.
Definition dependency_flux.hpp:135
void set_dependencies(std::vector< edge > &&deps) noexcept
Sets the set of dependencies.
Definition dependency_flux.hpp:140
uint32_t & get_right_span() noexcept
Returns a reference to the right span of this flux.
Definition dependency_flux.hpp:75
numeric::rational get_RL_ratio_rational() const noexcept
Returns the R/L ratio.
Definition dependency_flux.hpp:94
double get_RL_ratio() const noexcept
Returns the R/L ratio.
Definition dependency_flux.hpp:103
uint32_t get_size() const noexcept
Returns the size of this flux.
Definition dependency_flux.hpp:66
uint32_t & get_weight() noexcept
Returns a reference to the weight of this flux.
Definition dependency_flux.hpp:77
std::vector< edge > & get_dependencies()
Returns a reference to the set of dependencies.
Definition dependency_flux.hpp:80
uint32_t get_left_span() const noexcept
Returns left span of this flux.
Definition dependency_flux.hpp:62
numeric::rational get_WS_ratio_rational() const noexcept
Returns the W/S ratio.
Definition dependency_flux.hpp:113
void set_left_span(uint32_t ls) noexcept
Sets the left span.
Definition dependency_flux.hpp:128
const std::vector< edge > & get_dependencies() const noexcept
Returns the set of dependencies.
Definition dependency_flux.hpp:84
uint32_t m_weight
Weight of this flux.
Definition dependency_flux.hpp:163
uint32_t get_right_span() const noexcept
Returns right span of this flux.
Definition dependency_flux.hpp:64
std::vector< edge > m_dependencies
Dependencies in this flux.
Definition dependency_flux.hpp:156
void set_right_span(uint32_t rs) noexcept
Sets the right span.
Definition dependency_flux.hpp:130
void set_weight(uint32_t w) noexcept
Sets the weight.
Definition dependency_flux.hpp:132
uint32_t m_right_span
Definition dependency_flux.hpp:150
uint32_t get_weight() const noexcept
Returns weight of this flux.
Definition dependency_flux.hpp:69
uint32_t m_left_span
Definition dependency_flux.hpp:147
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:736
Main namespace of the library.
Definition definitions.hpp:48