aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
orderedEliminationSequenceStrategy.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48
49#ifndef GUM_ORDERED_ELIMINATION_SEQUENCE_STRATEGY_H
50#define GUM_ORDERED_ELIMINATION_SEQUENCE_STRATEGY_H
51
52#include <vector>
53
55
56namespace gum {
57
66 public:
67 // ############################################################################
69 // ############################################################################
71
74
76
88 const NodeProperty< Size >* dom_sizes,
89 const std::vector< NodeId >* order);
90
93
96
99
104 virtual OrderedEliminationSequenceStrategy* newFactory() const final;
105
107 virtual OrderedEliminationSequenceStrategy* copyFactory() const final;
108
110
111
112 // ############################################################################
114 // ############################################################################
116
118
129 virtual bool setGraph(UndiGraph* graph, const NodeProperty< Size >* dom_sizes) final;
130
132
142 virtual bool setOrder(const std::vector< NodeId >* order) final;
143
145 virtual void clear() final;
146
148
150 virtual NodeId nextNodeToEliminate() final;
151
158 virtual void askFillIns(bool do_it) final;
159
167 virtual bool providesFillIns() const final;
168
171 virtual bool providesGraphUpdate() const final;
172
174
176 virtual void eliminationUpdate(const NodeId node) final;
177
180 virtual const EdgeSet& fillIns() final;
181
183 const std::vector< NodeId >* order() const noexcept;
184
186
189 bool isOrderNeeded() const noexcept;
190
192
193
194 private:
196 const std::vector< NodeId >* _order_{nullptr};
197
199 std::size_t _order_index_{std::size_t(0)};
200
203 bool _order_needed_{true};
204
205
207 bool _isOrderNeeded_(const std::vector< NodeId >* order) const;
208 };
209
210
211} /* namespace gum */
212
213
214#ifndef GUM_NO_INLINE
216#endif // GU%_NO_INLINE
217
218
219#endif /* GUM_ORDERED_ELIMINATION_SEQUENCE_STRATEGY_H */
UndiGraph * graph() const noexcept
returns the current graph
virtual OrderedEliminationSequenceStrategy * copyFactory() const final
virtual copy constructor
virtual OrderedEliminationSequenceStrategy * newFactory() const final
creates a new elimination sequence of the same type as the current object, but this sequence contains...
virtual NodeId nextNodeToEliminate() final
returns the new node to be eliminated within the triangulation algorithm
bool isOrderNeeded() const noexcept
indicates whether a new complete ordering is needed
bool _isOrderNeeded_(const std::vector< NodeId > *order) const
indicates whether an order is compatible with the current graph
const std::vector< NodeId > * order() const noexcept
returns the current complete ordering
virtual const EdgeSet & fillIns() final
in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so ...
virtual bool providesFillIns() const final
indicates whether the fill-ins generated by the eliminated nodes, if needed, will be computed by the ...
const std::vector< NodeId > * _order_
the vector indicating in which order we should eliminate the nodes
bool _order_needed_
indicate whether a new complete ordering is necessary for the elimination
virtual bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes) final
sets a new graph to be triangulated
std::size_t _order_index_
the index in the order indicating the new node to eliminate
virtual void eliminationUpdate(const NodeId node) final
performs all the graph/fill-ins updates provided (if any)
virtual void askFillIns(bool do_it) final
if the elimination sequence is able to compute fill-ins, we indicate whether we want this feature to ...
virtual void clear() final
clears the order (to prepare, for instance, a new elimination sequence)
virtual bool providesGraphUpdate() const final
indicates whether the elimination sequence updates by itself the graph after a node has been eliminat...
virtual bool setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination
OrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
Base class for undirected graphs.
Definition undiGraph.h:128
Base Class for all elimination sequence algorithms used by triangulations.
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
An Elimination sequence algorithm that imposes a given complete ordering on the nodes elimination seq...