LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
D_rla.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// C++ includes
45#if defined DEBUG
46#include <cassert>
47#endif
48
49// lal includes
50#include <lal/numeric/rational.hpp>
51#include <lal/graphs/undirected_graph.hpp>
52#include <lal/graphs/free_tree.hpp>
53#include <lal/graphs/rooted_tree.hpp>
54
55namespace lal {
56namespace properties {
57
58// D: sum of length of edges
59
60/* ---------------------------- */
61/* EXPECTATION OF D: E_rla[D] */
62/* (unconstrained arrangements) */
63
74inline
76noexcept {
77 return numeric::rational((g.get_num_nodes() + 1)*g.get_num_edges(), 3);
78}
79
88inline
92
103inline
105noexcept {
106#if defined DEBUG
107 assert(t.is_tree());
108#endif
109 const uint32_t n = t.get_num_nodes();
110 return numeric::rational(n*n - 1, 3);
111}
112
121inline
122double exp_sum_edge_lengths(const graphs::free_tree& t) noexcept {
123#if defined DEBUG
124 assert(t.is_tree());
125#endif
127}
128
139inline
141noexcept {
142#if defined DEBUG
143 assert(t.is_rooted_tree());
144#endif
145 const uint32_t n = t.get_num_nodes();
146 return numeric::rational(n*n - 1, 3);
147}
148
157inline
158double exp_sum_edge_lengths(const graphs::rooted_tree& t) noexcept {
159#if defined DEBUG
160 assert(t.is_rooted_tree());
161#endif
163}
164
165
166/* ------------------------- */
167/* EXPECTATION OF D: E_pr[D] */
168/* (projective arrangements) */
169
183(const graphs::rooted_tree& rt) noexcept;
184
195inline
199
200
201/* ------------------------- */
202/* EXPECTATION OF D: E_pl[D] */
203/* (planar arrangements) */
204
218(const graphs::free_tree& t) noexcept;
231inline
235
266
267
268/* ---------------------------- */
269/* VARIANCE OF D: V_rla[D] */
270/* (unconstrained arrangements) */
271
283noexcept;
292inline
295
296} // -- namespace properties
297} // -- namespace lal
Free tree graph class.
Definition free_tree.hpp:59
Rooted tree graph class.
Definition rooted_tree.hpp:107
Undirected graph class.
Definition undirected_graph.hpp:67
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
numeric::rational var_sum_edge_lengths_rational(const graphs::undirected_graph &g) noexcept
Computes the variance of the sum of the length of edges of a graph, .
numeric::rational exp_sum_edge_lengths_rational(const graphs::undirected_graph &g) noexcept
Expected sum of edge lengths of an undirected graph in unconstrained arrangments, .
Definition D_rla.hpp:75
double exp_sum_edge_lengths(const graphs::undirected_graph &g) noexcept
Expected sum of edge lengths of an undirected graph in unconstrained arrangments, .
Definition D_rla.hpp:89
numeric::rational exp_sum_edge_lengths_projective_rational(const graphs::rooted_tree &rt) noexcept
Expected sum of edge lengths of a tree constrained to projective arrangments, .
double exp_sum_edge_lengths_planar(const graphs::free_tree &t) noexcept
Expected sum of edge lengths of a tree constrained to planar arrangments, .
Definition D_rla.hpp:249
double var_sum_edge_lengths(const graphs::undirected_graph &g) noexcept
Computes the variance of the sum of the length of edges of a graph, .
Definition D_rla.hpp:293
double exp_sum_edge_lengths_projective(const graphs::rooted_tree &rt) noexcept
Expected sum of edge lengths of a tree constrained to projective arrangments, .
Definition D_rla.hpp:196
numeric::rational exp_sum_edge_lengths_planar_rational(const graphs::free_tree &t) noexcept
Expected sum of edge lengths of a tree constrained to planar arrangments, .
Main namespace of the library.
Definition definitions.hpp:48