aGrUM 3.1.1
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-2026 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-2026 *
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#pragma once
42
43
49#include <limits>
50#include <sstream>
51
52#include <agrum/base/graphs/algorithms/simplicialSet.h> // to ease IDE parser
53
54#ifndef DOXYGEN_SHOULD_SKIP_THIS
55
56// to ease IDE parser
58
60
61namespace gum {
62
63 /* ===========================================================================
64 */
65 /* ===========================================================================
66 */
67 /* === CLASS FOR RETRIEVING SIMPLICIAL, ALMOST AND QUASI SIMPLICIAL NODES ===
68 */
69 /* ===========================================================================
70 */
71 /* ===========================================================================
72 */
73
75 INLINE
76 bool SimplicialSet::isSimplicial(const NodeId id) {
77 // update the list to which the node belongs if needed
78 if (_changed_status_.contains(id)) _updateList_(id);
79
80 // check if the node belongs to the simplicial list
81 return _simplicial_nodes_.contains(id);
82 }
83
85 INLINE
87 if (!hasSimplicialNode()) { GUM_ERROR(NotFound, "No simplicial node could be found") }
88
89 return _simplicial_nodes_.top();
90 }
91
93 INLINE
96 GUM_ERROR(NotFound, "no almost simplicial node could be found")
97 }
98
99 return _almost_simplicial_nodes_.top();
100 }
101
103 INLINE
105 if (!hasQuasiSimplicialNode()) {
106 GUM_ERROR(NotFound, "no quasi simplicial node could be found")
107 }
108
109 return _quasi_simplicial_nodes_.top();
110 }
111
113 INLINE
115 // check if a node can enter the simplicial list
116 for (auto iter = _changed_status_.beginSafe(); // safe iterator needed here
117 iter != _changed_status_.endSafe();
118 ++iter) {
119 _updateList_(*iter);
120 }
121 }
122
124 INLINE
127 return _simplicial_nodes_;
128 }
129
131 INLINE
135 }
136
138 INLINE
142 }
143
145 INLINE
147
149 INLINE
150 const EdgeSet& SimplicialSet::fillIns() const { return _fill_ins_list_; }
151
152
153} /* namespace gum */
154
155#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:76
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
Class for fast retrieval of simplicial and quasi/almost simplicial nodes.