aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
binaryJoinTreeConverterDefault.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 algorithm for converting a join tree into a binary join tree
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_BINARY_JOIN_TREE_CONVERTER_DEFAULT_H
28 #define GUM_BINARY_JOIN_TREE_CONVERTER_DEFAULT_H
29 
30 #include <agrum/tools/graphs/algorithms/binaryJoinTreeConverter.h>
31 
32 namespace gum {
33 
35  public:
36  // ############################################################################
37  /// @name Constructors / Destructors
38  // ############################################################################
39  /// @{
40 
41  /// default constructor
43 
44  /// destructor
46 
47  /// @}
48 
49  // ############################################################################
50  /// @name Accessors/Modifiers
51  // ############################################################################
52  /// @{
53 
54  /// returns a binary join tree corresponding to clique graph JT
55  /** This method creates and returns a new binary join tree compatible with
56  * that passed in argument (JT) and optimized for inference. As such, this
57  * requires knowing the join tree to be converted (of course), but also
58  * which roots will be used by the collect/diffusion inference engine and
59  * the domain size of the variables contained in the cliques of JT (to
60  * optimize the combination of the potentials contained in the cliques.
61  * @throws InvalidNode exception is thrown if some roots do not belong to
62  * JT or if several roots belong to the same connected component.
63  * @warning If you do not pass in argument a root for each connected
64  * component,
65  * then for those with unspecified roots, an arbitrary root will be computed
66  * and used for the binarization. */
68  const NodeProperty< Size >& domain_sizes,
69  const NodeSet& roots);
70 
71  /// returns all the roots considered for all the connected components
72  const NodeSet& roots() const;
73 
74  /// @}
75 
76  private:
77  /// the new roots that have been created to compute the last query
79 
80  /// forbid copy constructor
82 
83  /// forbid copy operator
85 
86  /** @brief a function used to mark the nodes belonging to a given
87  * connected component */
88  void _markConnectedComponent_(const CliqueGraph& JT,
89  NodeId root,
90  NodeProperty< bool >& mark) const;
91 
92  /// convert a whole connected component into a binary join tree
93  void _convertConnectedComponent_(CliqueGraph& JT,
94  NodeId current_node,
95  NodeId from,
96  const NodeProperty< Size >& domain_sizes,
97  NodeProperty< bool >& mark) const;
98 
99  /// convert a clique and its adjacent cliques into a binary join tree
100  void _convertClique_(CliqueGraph& JT,
101  NodeId clique,
102  NodeId from,
103  const NodeProperty< Size >& domain_sizes) const;
104 
105  /// returns the domain size of the union of two cliques
106  float _combinedSize_(const NodeSet& nodes1,
107  const NodeSet& nodes2,
108  const NodeProperty< Size >& domain_sizes) const;
109  };
110 
111 } /* namespace gum */
112 
113 #endif /* GUM_BINARY_JOIN_TREE_CONVERTER_DEFAULT_H */
BinaryJoinTreeConverterDefault & operator=(const BinaryJoinTreeConverterDefault &)
forbid copy operator
NodeSet _roots_
the new roots that have been created to compute the last query
CliqueGraph convert(const CliqueGraph &JT, const NodeProperty< Size > &domain_sizes, const NodeSet &roots)
returns a binary join tree corresponding to clique graph JT
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
void _convertConnectedComponent_(CliqueGraph &JT, NodeId current_node, NodeId from, const NodeProperty< Size > &domain_sizes, NodeProperty< bool > &mark) const
convert a whole connected component into a binary join tree
void _markConnectedComponent_(const CliqueGraph &JT, NodeId root, NodeProperty< bool > &mark) const
a function used to mark the nodes belonging to a given connected component
const NodeSet & roots() const
returns all the roots considered for all the connected components
float _combinedSize_(const NodeSet &nodes1, const NodeSet &nodes2, const NodeProperty< Size > &domain_sizes) const
returns the domain size of the union of two cliques
BinaryJoinTreeConverterDefault(const BinaryJoinTreeConverterDefault &)
forbid copy constructor
void _convertClique_(CliqueGraph &JT, NodeId clique, NodeId from, const NodeProperty< Size > &domain_sizes) const
convert a clique and its adjacent cliques into a binary join tree