aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
defaultJunctionTreeStrategy.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 An algorithms producing a junction given the elimination tree
24  * produced by the triangulation algorithm
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_DEFAULT_JUNCTION_TREE_STRATEGY_H
30 #define GUM_DEFAULT_JUNCTION_TREE_STRATEGY_H
31 
32 #include <agrum/tools/graphs/algorithms/triangulations/junctionTreeStrategies/junctionTreeStrategy.h>
33 
34 namespace gum {
35 
36  /** @class DefaultJunctionTreeStrategy
37  * @brief An algorithm producing a junction given the elimination tree
38  * produced by a triangulation algorithm
39  *
40  * \ingroup graph_group
41  *
42  */
44  public:
45  // ############################################################################
46  /// @name Constructors / Destructors
47  // ############################################################################
48  /// @{
49 
50  /// default constructor
52 
53  /// copy constructor
55 
56  /// move constructor
58 
59  /// destructor
60  virtual ~DefaultJunctionTreeStrategy();
61 
62  /// create a clone not assigned to any triangulation algorithm
63  virtual DefaultJunctionTreeStrategy* newFactory() const final;
64 
65  /// virtual copy constructor
66  /** @param triangulation if triangulation is different from nullptr, this
67  * becomes the new triangulation algorithm associated with the junction tree
68  * strategy */
69  virtual DefaultJunctionTreeStrategy* copyFactory(StaticTriangulation* triangulation
70  = nullptr) const final;
71 
72  /// @}
73 
74 
75  // ############################################################################
76  /// @name Accessors / Modifiers
77  // ############################################################################
78  /// @{
79 
80  /** @brief indicates whether the junction tree strategy needs fill-ins
81  * to work properly
82  *
83  * If the junctionTreeStrategy needs fill-ins to work properly, its
84  * assigned triangulation instance (see method setTriangulation) will be
85  * commited to compute them. */
86  virtual bool requiresFillIns() const final;
87 
88  /// returns the junction tree computed
89  /** The idea behind this method is that the JunctionTreeStrategy asks its
90  * assigned triangulation (see method setTriangulation) all the data it
91  * needs to compute correctly the junction tree. For instance, it may asks
92  * for a triangulated graph or an elimination tree, or even the order of
93  * elimination of the nodes, etc. All these data are available from the
94  * triangulation class. Knowing these data, the junctionTreeStrategy
95  * computes and returns a junction tree corresponding to the triangulated
96  * graph.
97  * @throws UndefinedElement is raised if no triangulation has been assigned
98  * to the DefaultJunctionTreeStrategy */
99  virtual const CliqueGraph& junctionTree() final;
100 
101  /// assigns the triangulation to the junction tree strategy
102  /** @param the triangulation whose resulting cliques will be used to
103  * construct the junction tree
104  * @warning note that, by aGrUM's rule, the graph and the domain sizes
105  * are not copied but only referenced by the junction tree strategy. */
106  virtual void setTriangulation(StaticTriangulation* triangulation) final;
107 
108  /** @brief returns, for each node, the clique of the junction tree which was
109  * created by its deletion
110  * @throws UndefinedElement is raised if no triangulation has been assigned
111  * to the DefaultJunctionTreeStrategy */
112  virtual const NodeProperty< NodeId >& createdCliques() final;
113 
114  /** @brief returns the Id of the clique of the junction tree created by the
115  * elimination of a given node during the triangulation process
116  * @param id the id of the node in the original undirected graph whose
117  * created clique's id is looked for
118  * @throws UndefinedElement is raised if no triangulation has been assigned
119  * to the DefaultJunctionTreeStrategy */
120  virtual NodeId createdClique(const NodeId id) final;
121 
122  /// resets the current junction tree strategy data structures
123  virtual void clear() final;
124 
125  /// @}
126 
127  private:
128  /// a boolean indicating whether the junction tree has been constructed
129  bool _has_junction_tree_{false};
130 
131  /// the junction tree computed by the algorithm
133 
134  /** @brief indicates which clique of the junction tree was created
135  * by the elimination of a given node (the key of the table) */
137 
138  /// computes a junction tree from an elimination tree
139  void _computeJunctionTree_();
140  };
141 
142 } /* namespace gum */
143 
144 #endif /* GUM_DEFAULT_JUNCTION_TREE_STRATEGY_H */
virtual NodeId createdClique(const NodeId id) final
returns the Id of the clique of the junction tree created by the elimination of a given node during t...
void _computeJunctionTree_()
computes a junction tree from an elimination tree
virtual DefaultJunctionTreeStrategy * copyFactory(StaticTriangulation *triangulation=nullptr) const final
virtual copy constructor
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual DefaultJunctionTreeStrategy * newFactory() const final
create a clone not assigned to any triangulation algorithm
virtual void setTriangulation(StaticTriangulation *triangulation) final
assigns the triangulation to the junction tree strategy
DefaultJunctionTreeStrategy(DefaultJunctionTreeStrategy &&from)
move constructor
virtual const NodeProperty< NodeId > & createdCliques() final
returns, for each node, the clique of the junction tree which was created by its deletion ...
bool _has_junction_tree_
a boolean indicating whether the junction tree has been constructed
NodeProperty< NodeId > _node_2_junction_clique_
indicates which clique of the junction tree was created by the elimination of a given node (the key o...
virtual bool requiresFillIns() const final
indicates whether the junction tree strategy needs fill-ins to work properly
DefaultJunctionTreeStrategy(const DefaultJunctionTreeStrategy &from)
copy constructor
virtual void clear() final
resets the current junction tree strategy data structures
virtual const CliqueGraph & junctionTree() final
returns the junction tree computed
CliqueGraph _junction_tree_
the junction tree computed by the algorithm
An algorithm producing a junction given the elimination tree produced by a triangulation algorithm...