aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
simplicialSet_inl.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#pragma once
41
42
48#include <limits>
49#include <sstream>
50
51#ifndef DOXYGEN_SHOULD_SKIP_THIS
52
53// to ease IDE parser
55
57
58namespace gum {
59
60 /* ===========================================================================
61 */
62 /* ===========================================================================
63 */
64 /* === CLASS FOR RETRIEVING SIMPLICIAL, ALMOST AND QUASI SIMPLICIAL NODES ===
65 */
66 /* ===========================================================================
67 */
68 /* ===========================================================================
69 */
70
72 INLINE
73 bool SimplicialSet::isSimplicial(const NodeId id) {
74 // update the list to which the node belongs if needed
75 if (_changed_status_.contains(id)) _updateList_(id);
76
77 // check if the node belongs to the simplicial list
78 return _simplicial_nodes_.contains(id);
79 }
80
82 INLINE
84 if (!hasSimplicialNode()) { GUM_ERROR(NotFound, "No simplicial node could be found") }
85
86 return _simplicial_nodes_.top();
87 }
88
90 INLINE
93 GUM_ERROR(NotFound, "no almost simplicial node could be found")
94 }
95
96 return _almost_simplicial_nodes_.top();
97 }
98
100 INLINE
102 if (!hasQuasiSimplicialNode()) {
103 GUM_ERROR(NotFound, "no quasi simplicial node could be found")
104 }
105
106 return _quasi_simplicial_nodes_.top();
107 }
108
110 INLINE
112 // check if a node can enter the simplicial list
113 for (auto iter = _changed_status_.beginSafe(); // safe iterator needed here
114 iter != _changed_status_.endSafe();
115 ++iter) {
116 _updateList_(*iter);
117 }
118 }
119
121 INLINE
124 return _simplicial_nodes_;
125 }
126
128 INLINE
132 }
133
135 INLINE
139 }
140
142 INLINE
144
146 INLINE
147 const EdgeSet& SimplicialSet::fillIns() const { return _fill_ins_list_; }
148
149
150} /* namespace gum */
151
152#endif /* DOXYGEN_SHOULD_SKIP_THIS */
const PriorityQueue< NodeId, double > & allSimplicialNodes()
returns all the simplicial nodes
void _updateList_(const NodeId id)
put node id in the correct simplicial/almost simplicial/quasi simplicial list
NodeId bestSimplicialNode()
returns the simplicial node with the lowest clique weight
bool hasSimplicialNode()
indicates whether there exists a simplicial node
void _updateAllNodes_()
put all the nodes in their appropriate list
bool hasAlmostSimplicialNode()
indicates whether there exists an almost simplicial node
bool isSimplicial(const NodeId id)
indicates whether a given node is a simplicial node
NodeId bestAlmostSimplicialNode()
gets the almost simplicial node with the lowest clique weight
const PriorityQueue< NodeId, double > & allQuasiSimplicialNodes()
returns all the quasi simplicial nodes
NodeId bestQuasiSimplicialNode()
gets a quasi simplicial node with the lowest clique weight
const PriorityQueue< NodeId, double > & allAlmostSimplicialNodes()
returns all the almost simplicial nodes
void setFillIns(bool on_off)
sets/unset the fill-ins storage in the standard triangulation procedure
bool _we_want_fill_ins_
a boolean indicating if we want fill-ins list with the standard triangulation method
PriorityQueue< NodeId, double > _almost_simplicial_nodes_
a queue of the almost simplicial nodes ordered by increasing node weight
PriorityQueue< NodeId, double > _quasi_simplicial_nodes_
a queue of the quasi simplicial nodes ordered by increasing node weight
NodeSet _changed_status_
the set of nodes that have tensorly changed of status
bool hasQuasiSimplicialNode()
indicates whether there exists a quasi simplicial node
PriorityQueue< NodeId, double > _simplicial_nodes_
a queue of the simplicial nodes ordered by increasing node weight
EdgeSet _fill_ins_list_
fill-ins list
const EdgeSet & fillIns() const
returns the set of all the fill-ins added to the graph so far
An Elimination sequence algorithm that imposes a given partial ordering on the nodes elimination sequ...
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
Useful macros for maths.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46