LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
all_ulab_free_bistar_trees.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/free_tree.hpp>
46#include <lal/generate/tree_generator.hpp>
47#include <lal/detail/array.hpp>
48
49namespace lal {
50namespace generate {
51
98class all_ulab_free_bistar_trees : public _tree_generator<graphs::free_tree> {
99public:
101 all_ulab_free_bistar_trees() noexcept : _tree_generator<graphs::free_tree>() { }
102
107 all_ulab_free_bistar_trees(const uint64_t n) noexcept {
108 init(n);
109 }
115
121
123 ~all_ulab_free_bistar_trees() noexcept = default;
124
126 all_ulab_free_bistar_trees& operator= (const all_ulab_free_bistar_trees& g) noexcept = default;
128 all_ulab_free_bistar_trees& operator= (all_ulab_free_bistar_trees&& g) noexcept = default;
129
130 /* INITIALIZE */
131
136 void init(const uint64_t n) noexcept {
138 m_size = 0;
139 reset();
140 }
141
146 void clear() noexcept {
148 }
149
150 /* GETTERS */
151
153 [[nodiscard]] bool end() const noexcept {
154 return m_n == 0 ? true : m_size >= m_n/2;
155 }
156
157 /* MODIFIERS */
158
166 void next() noexcept {
167 ++m_size;
168 }
169
171 void reset() noexcept {
172 m_size = 0;
173 }
174
175 [[nodiscard]] graphs::free_tree yield_tree() noexcept {
176 const auto t = get_tree();
177 next();
178 return t;
179 }
180
181protected:
188 [[nodiscard]] graphs::free_tree __get_tree() noexcept;
189
190private:
192 uint64_t m_size;
193};
194
195} // -- namespace generate
196} // -- namespace lal
Base class for tree generators.
Definition tree_generator.hpp:123
uint64_t m_n
Definition tree_generator.hpp:300
void clear() noexcept
Clears the memory used by the generator.
Definition tree_generator.hpp:166
void init(const uint64_t n) noexcept
Initializes the tree generator.
Definition tree_generator.hpp:160
graphs::free_tree get_tree() noexcept
Definition tree_generator.hpp:196
Exhaustive enumeration of unlabelled free trees.
Definition all_ulab_free_bistar_trees.hpp:98
graphs::free_tree yield_tree() noexcept
Yields a tree, advancing the generator if necessary.
Definition all_ulab_free_bistar_trees.hpp:175
uint64_t m_size
The size of the left partition.
Definition all_ulab_free_bistar_trees.hpp:192
all_ulab_free_bistar_trees() noexcept
Empty constructor.
Definition all_ulab_free_bistar_trees.hpp:101
all_ulab_free_bistar_trees(const all_ulab_free_bistar_trees &Gen) noexcept=default
Copy constructor.
all_ulab_free_bistar_trees(all_ulab_free_bistar_trees &&Gen) noexcept=default
Move constructor.
void init(const uint64_t n) noexcept
Initializes the generator with a given number of vertices.
Definition all_ulab_free_bistar_trees.hpp:136
graphs::free_tree __get_tree() noexcept
Constructs the current tree.
void reset() noexcept
Sets the generator to its initial state.
Definition all_ulab_free_bistar_trees.hpp:171
all_ulab_free_bistar_trees(const uint64_t n) noexcept
Constructor with number of nodes.
Definition all_ulab_free_bistar_trees.hpp:107
void clear() noexcept
Clears the memory used.
Definition all_ulab_free_bistar_trees.hpp:146
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition all_ulab_free_bistar_trees.hpp:153
void next() noexcept
Generates next tree.
Definition all_ulab_free_bistar_trees.hpp:166
~all_ulab_free_bistar_trees() noexcept=default
Default destructor.
Free tree graph class.
Definition free_tree.hpp:60
Main namespace of the library.
Definition basic_types.hpp:48