LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
all_ulab_rooted_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 - 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/graphs/rooted_tree.hpp>
46#include <lal/generate/tree_generator.hpp>
47#include <lal/internal/data_array.hpp>
48
49namespace lal {
50namespace generate {
51
99class all_ulab_rooted_trees : public _tree_generator<graphs::rooted_tree> {
100public:
101 /* CONSTRUCTORS */
102
107 all_ulab_rooted_trees(uint32_t n) noexcept;
113#ifndef SWIG
119#endif
121 ~all_ulab_rooted_trees() noexcept = default;
122
123 /* GETTERS */
124
126 inline bool end() const noexcept { return m_reached_end; }
127
128 /* MODIFIERS */
129
137 void next() noexcept;
138
140 inline void reset() noexcept {
141 __reset();
142 next();
143 }
144
145 inline graphs::rooted_tree yield_tree() noexcept {
146 const auto t = get_tree();
147 next();
148 return t;
149 }
150
151protected:
160
162 void __reset() noexcept;
163
164private:
166 bool m_is_last = false;
168 bool m_is_first = false;
170 bool m_reached_end = false;
171
173 uint32_t m_p = 0;
175 internal::data_array<node> m_save;
177 internal::data_array<node> m_prev;
179 internal::data_array<node> m_L;
180};
181
182} // -- namespace generate
183} // -- namespace lal
Base class for tree generators.
Definition tree_generator.hpp:87
tree_type_t get_tree() noexcept
Definition tree_generator.hpp:146
Exhaustive enumeration of unlabelled rooted trees.
Definition all_ulab_rooted_trees.hpp:99
void next() noexcept
Generates the next tree.
internal::data_array< node > m_save
Sequence SAVE.
Definition all_ulab_rooted_trees.hpp:175
all_ulab_rooted_trees(all_ulab_rooted_trees &&Gen)=delete
Move constructor.
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition all_ulab_rooted_trees.hpp:126
graphs::rooted_tree yield_tree() noexcept
Yields a tree, advancing the generator if necessary.
Definition all_ulab_rooted_trees.hpp:145
bool m_reached_end
Has the end of the generation been reached?
Definition all_ulab_rooted_trees.hpp:170
graphs::rooted_tree __get_tree() noexcept
Constructs the current tree.
internal::data_array< node > m_prev
Sequence PREV.
Definition all_ulab_rooted_trees.hpp:177
void reset() noexcept
Sets the generator to its initial state.
Definition all_ulab_rooted_trees.hpp:140
internal::data_array< node > m_L
Level sequence of the tree.
Definition all_ulab_rooted_trees.hpp:179
void __reset() noexcept
Sets the generator to its initial state.
all_ulab_rooted_trees(uint32_t n) noexcept
Constructor with number of nodes.
uint32_t m_p
Pointer as in the paper.
Definition all_ulab_rooted_trees.hpp:173
bool m_is_last
Is the current tree the last tree to be generated?
Definition all_ulab_rooted_trees.hpp:166
bool m_is_first
Is the current tree the first tree to be generated?
Definition all_ulab_rooted_trees.hpp:168
~all_ulab_rooted_trees() noexcept=default
Default destructor.
all_ulab_rooted_trees(const all_ulab_rooted_trees &Gen)=default
Copy constructor.
Rooted tree graph class.
Definition rooted_tree.hpp:107
Main namespace of the library.
Definition definitions.hpp:48
uint32_t node
Node type.
Definition definitions.hpp:51