LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
crossings.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// C++ includes
45#include <vector>
46
47// lal includes
48#include <lal/linear_arrangement.hpp>
49#include <lal/graphs/graph.hpp>
50#include <lal/graphs/directed_graph.hpp>
51#include <lal/graphs/undirected_graph.hpp>
52
53namespace lal {
54namespace detail {
55
56/*
57 * This file is a summary of the functions that implement the different
58 * algorithms to calculate the number of edge crossings.
59 */
60
72template <class graph_t>
73[[nodiscard]] uint64_t n_C_brute_force
74(const graph_t& g, const linear_arrangement& arr)
75noexcept;
76
90template <class graph_t>
91[[nodiscard]] std::vector<uint64_t> n_C_brute_force
92(const graph_t& g, const std::vector<linear_arrangement>& arrs)
93noexcept;
94
110template <class graph_t>
111[[nodiscard]] uint64_t is_n_C_brute_force_lesseq_than
112(
113 const graph_t& g,
114 const linear_arrangement& arr,
115 const uint64_t upper_bound
116)
117noexcept;
118
137template <class graph_t>
138[[nodiscard]] std::vector<uint64_t> is_n_C_brute_force_lesseq_than
139(
140 const graph_t& g,
141 const std::vector<linear_arrangement>& arrs,
142 const uint64_t upper_bound
143)
144noexcept;
145
165template <class graph_t>
166[[nodiscard]] std::vector<uint64_t> is_n_C_brute_force_lesseq_than
167(
168 const graph_t& g,
169 const std::vector<linear_arrangement>& arrs,
170 const std::vector<uint64_t>& upper_bounds
171)
172noexcept;
173
174// -----------------------------------------------------------------------------
175
187template <class graph_t>
188[[nodiscard]] uint64_t n_C_dynamic_programming
189(const graph_t& g, const linear_arrangement& arr)
190noexcept;
191
205template <class graph_t>
206[[nodiscard]] std::vector<uint64_t> n_C_dynamic_programming
207(const graph_t& g, const std::vector<linear_arrangement>& arrs)
208noexcept;
209
228template <class graph_t>
230(
231 const graph_t& g,
232 const linear_arrangement& arr,
233 const uint64_t upper_bound
234)
235noexcept;
236
256template <class graph_t>
257[[nodiscard]] std::vector<uint64_t> is_n_C_dynamic_programming_lesseq_than
258(
259 const graph_t& g,
260 const std::vector<linear_arrangement>& arrs,
261 const uint64_t upper_bound
262)
263noexcept;
264
284template <class graph_t>
285[[nodiscard]] std::vector<uint64_t> is_n_C_dynamic_programming_lesseq_than
286(
287 const graph_t& g,
288 const std::vector<linear_arrangement>& arrs,
289 const std::vector<uint64_t>& upper_bounds
290)
291noexcept;
292
293// -----------------------------------------------------------------------------
294
306template <class graph_t>
307[[nodiscard]] uint64_t n_C_ladder
308(const graph_t& g, const linear_arrangement& arr)
309noexcept;
310
324template <class graph_t>
325[[nodiscard]] std::vector<uint64_t> n_C_ladder
326(const graph_t& g, const std::vector<linear_arrangement>& arrs)
327noexcept;
328
344template <class graph_t>
345[[nodiscard]] uint64_t is_n_C_ladder_lesseq_than
346(
347 const graph_t& g,
348 const linear_arrangement& arr,
349 const uint64_t upper_bound
350)
351noexcept;
352
372template <class graph_t>
373[[nodiscard]] std::vector<uint64_t> is_n_C_ladder_lesseq_than
374(
375 const graph_t& g,
376 const std::vector<linear_arrangement>& arrs,
377 const uint64_t upper_bound
378)
379noexcept;
380
400template <class graph_t>
401[[nodiscard]] std::vector<uint64_t> is_n_C_ladder_lesseq_than
402(
403 const graph_t& g,
404 const std::vector<linear_arrangement>& arrs,
405 const std::vector<uint64_t>& upper_bounds
406)
407noexcept;
408
409// -----------------------------------------------------------------------------
410
422template <class graph_t>
423[[nodiscard]] uint64_t n_C_stack_based
424(const graph_t& g, const linear_arrangement& arr)
425noexcept;
426
440template <class graph_t>
441[[nodiscard]] std::vector<uint64_t> n_C_stack_based
442(const graph_t& g, const std::vector<linear_arrangement>& arrs)
443noexcept;
444
460template <class graph_t>
461[[nodiscard]] uint64_t is_n_C_stack_based_lesseq_than
462(
463 const graph_t& g,
464 const linear_arrangement& arr,
465 const uint64_t upper_bound
466)
467noexcept;
468
488template <class graph_t>
489[[nodiscard]] std::vector<uint64_t> is_n_C_stack_based_lesseq_than
490(
491 const graph_t& g,
492 const std::vector<linear_arrangement>& arrs,
493 const uint64_t upper_bound
494)
495noexcept;
496
516template <class graph_t>
517[[nodiscard]] std::vector<uint64_t> is_n_C_stack_based_lesseq_than
518(
519 const graph_t& g,
520 const std::vector<linear_arrangement>& arrs,
521 const std::vector<uint64_t>& upper_bounds
522)
523noexcept;
524
525} // -- namespace detail
526} // -- namespace lal
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103
uint64_t is_n_C_stack_based_lesseq_than(const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept
Fast calculation of if it is less than or equal to an upper bound.
uint64_t n_C_ladder(const graph_t &g, const linear_arrangement &arr) noexcept
Is the number of crossings in the linear arrangement less than a constant?
uint64_t n_C_stack_based(const graph_t &g, const linear_arrangement &arr) noexcept
Is the number of crossings in the linear arrangement less than a constant?
uint64_t is_n_C_dynamic_programming_lesseq_than(const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept
Fast calculation of if it is less than or equal to an upper bound.
uint64_t n_C_brute_force(const graph_t &g, const linear_arrangement &arr) noexcept
Is the number of crossings in the linear arrangement less than a constant?
uint64_t is_n_C_ladder_lesseq_than(const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept
Fast calculation of if it is less than or equal to an upper bound.
uint64_t n_C_dynamic_programming(const graph_t &g, const linear_arrangement &arr) noexcept
Is the number of crossings in the linear arrangement less than a constant?
uint64_t is_n_C_brute_force_lesseq_than(const graph_t &g, const linear_arrangement &arr, const uint64_t upper_bound) noexcept
Returns whether the number of crossings is less than a given constant.
Main namespace of the library.
Definition basic_types.hpp:48