aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
staticTriangulation_inl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/** @file
23
* @brief Inline implementations for computing default triangulations of graphs
24
*
25
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26
*/
27
28
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
29
30
31
namespace
gum
{
32
33
34
/// returns an elimination ordering compatible with the triangulated graph
35
INLINE
36
const
std
::
vector
<
NodeId
>&
StaticTriangulation
::
eliminationOrder
() {
37
if
(!
_has_triangulation_
)
_triangulate_
();
38
39
return
_elim_order_
;
40
}
41
42
43
/** @brief returns the index of a given node in the elimination order
44
* (0 = first node eliminated) */
45
INLINE
46
Idx
StaticTriangulation
::
eliminationOrder
(
const
NodeId
id
) {
47
if
(!
_has_triangulation_
)
_triangulate_
();
48
49
return
_reverse_elim_order_
[
id
];
50
}
51
52
53
/** @brief returns the number of a given node in the elimination order
54
* (0 = first node eliminated) */
55
INLINE
56
const
NodeProperty
<
NodeId
>&
StaticTriangulation
::
reverseEliminationOrder
() {
57
if
(!
_has_triangulation_
)
_triangulate_
();
58
59
return
_reverse_elim_order_
;
60
}
61
62
63
/// returns the elimination tree of a compatible ordering
64
INLINE
65
const
CliqueGraph
&
StaticTriangulation
::
eliminationTree
() {
66
if
(!
_has_elimination_tree_
)
_computeEliminationTree_
();
67
68
return
_elim_tree_
;
69
}
70
71
72
/// returns a compatible junction tree
73
INLINE
74
const
CliqueGraph
&
StaticTriangulation
::
junctionTree
() {
75
// checks if junctionTree already exists
76
if
(!
_has_junction_tree_
) {
77
_junction_tree_
= &(
junction_tree_strategy_
->
junctionTree
());
78
_has_junction_tree_
=
true
;
79
}
80
81
return
*
_junction_tree_
;
82
}
83
84
85
/// returns a junction tree of maximal prime subgraphs
86
INLINE
87
const
CliqueGraph
&
StaticTriangulation
::
maxPrimeSubgraphTree
() {
88
if
(!
_has_max_prime_junction_tree_
)
_computeMaxPrimeJunctionTree_
();
89
90
return
_max_prime_junction_tree_
;
91
}
92
93
94
/** @brief returns the Id of the maximal prime subgraph created by the
95
* elimination of a given node during the triangulation process */
96
INLINE
97
NodeId
StaticTriangulation
::
createdMaxPrimeSubgraph
(
const
NodeId
id
) {
98
if
(!
_has_max_prime_junction_tree_
)
_computeMaxPrimeJunctionTree_
();
99
100
return
_node_2_max_prime_clique_
[
id
];
101
}
102
103
104
/** @brief returns the Id of the clique created by the
105
* elimination of a given node during the triangulation process */
106
INLINE
107
NodeId
StaticTriangulation
::
createdJunctionTreeClique
(
const
NodeId
id
) {
108
return
junction_tree_strategy_
->
createdClique
(
id
);
109
}
110
111
112
/** @brief returns the Ids of the cliques of the junction tree created by the
113
* elimination of the nodes */
114
INLINE
115
const
NodeProperty
<
NodeId
>&
StaticTriangulation
::
createdJunctionTreeCliques
() {
116
return
junction_tree_strategy_
->
createdCliques
();
117
}
118
119
120
/// sets/unset the fill-ins storage in the standard triangulation procedure
121
INLINE
122
void
StaticTriangulation
::
setFillIns
(
bool
b
) {
123
_we_want_fill_ins_
=
b
;
124
elimination_sequence_strategy_
->
askFillIns
(
b
);
125
}
126
127
128
/// returns the graph to be triangulated
129
INLINE
130
const
UndiGraph
*
StaticTriangulation
::
originalGraph
()
const
{
return
_original_graph_
; }
131
132
133
/// returns the elimination sequence strategy used by the triangulation
134
INLINE
EliminationSequenceStrategy
&
StaticTriangulation
::
eliminationSequenceStrategy
()
const
{
135
return
*
elimination_sequence_strategy_
;
136
}
137
138
139
/// returns the junction tree strategy used by the triangulation
140
INLINE
JunctionTreeStrategy
&
StaticTriangulation
::
junctionTreeStrategy
()
const
{
141
return
*
junction_tree_strategy_
;
142
}
143
144
145
/// indicates wether minimality is required
146
INLINE
bool
StaticTriangulation
::
isMinimalityRequired
()
const
{
return
_minimality_required_
; }
147
148
149
}
/* namespace gum */
150
151
152
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643