aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
binaryJoinTreeConverterDefault.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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
86 
87  /** @brief a function used to mark the nodes belonging to a given
88  * connected component */
89  void markConnectedComponent__(const CliqueGraph& JT,
90  NodeId root,
91  NodeProperty< bool >& mark) const;
92 
93  /// convert a whole connected component into a binary join tree
94  void convertConnectedComponent__(CliqueGraph& JT,
95  NodeId current_node,
96  NodeId from,
97  const NodeProperty< Size >& domain_sizes,
98  NodeProperty< bool >& mark) const;
99 
100  /// convert a clique and its adjacent cliques into a binary join tree
101  void convertClique__(CliqueGraph& JT,
102  NodeId clique,
103  NodeId from,
104  const NodeProperty< Size >& domain_sizes) const;
105 
106  /// returns the domain size of the union of two cliques
107  float combinedSize__(const NodeSet& nodes1,
108  const NodeSet& nodes2,
109  const NodeProperty< Size >& domain_sizes) const;
110  };
111 
112 } /* namespace gum */
113 
114 #endif /* GUM_BINARY_JOIN_TREE_CONVERTER_DEFAULT_H */
BinaryJoinTreeConverterDefault & operator=(const BinaryJoinTreeConverterDefault &)
forbid copy operator
CliqueGraph convert(const CliqueGraph &JT, const NodeProperty< Size > &domain_sizes, const NodeSet &roots)
returns a binary join tree corresponding to clique graph JT
NodeSet roots__
the new roots that have been created to compute the last query
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
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
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
void markConnectedComponent__(const CliqueGraph &JT, NodeId root, NodeProperty< bool > &mark) const
a function used to mark the nodes belonging to a given connected component