LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
all_arrangements.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/graphs/graph.hpp>
46#include <lal/linear_arrangement.hpp>
47
48namespace lal {
49namespace generate {
50
106public:
112 : all_arrangements(g.get_num_nodes())
113 { }
114
119 all_arrangements(const uint64_t n) noexcept
120 : m_n(n),
122 {
123 reset();
124 }
125
134 [[nodiscard]] const linear_arrangement& get_arrangement() const noexcept
135 { return m_arr; }
136
138 [[nodiscard]] bool end() const noexcept { return m_reached_end; }
139
146 void next() noexcept;
147
149 void reset() noexcept {
150 m_reached_end = false;
151 m_arr.identity();
152 }
153
159 [[nodiscard]] linear_arrangement yield_arrangement() noexcept {
160 // yes, a copy...
162 next();
163 return arr;
164 }
165
166private:
168 const uint64_t m_n;
176 bool m_reached_end = false;
177};
178
179} // -- namespace generate
180} // -- namespace lal
Exhaustive enumeration of arrangements of any graph.
Definition all_arrangements.hpp:105
const linear_arrangement & get_arrangement() const noexcept
Returns the current linear arrangemnt.
Definition all_arrangements.hpp:134
all_arrangements(const uint64_t n) noexcept
Constructor with number of vertices.
Definition all_arrangements.hpp:119
bool m_reached_end
Has the end of the iteration been reached?
Definition all_arrangements.hpp:176
const uint64_t m_n
Number of vertices.
Definition all_arrangements.hpp:168
void next() noexcept
Generates the next arrangement.
linear_arrangement m_arr
The arrangement generated by this class.
Definition all_arrangements.hpp:174
all_arrangements(const lal::graphs::graph &g) noexcept
Constructor with graph.
Definition all_arrangements.hpp:111
void reset() noexcept
Sets the generator to its initial state.
Definition all_arrangements.hpp:149
linear_arrangement yield_arrangement() noexcept
Constructs the current arrangement.
Definition all_arrangements.hpp:159
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition all_arrangements.hpp:138
Abstract class for graphs.
Definition graph.hpp:68
Linear arrangement of vertices.
Definition linear_arrangement.hpp:103
static linear_arrangement identity(std::size_t n) noexcept
Constructs an identity linear arrangement.
Definition linear_arrangement.hpp:494
Main namespace of the library.
Definition basic_types.hpp:48