aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
defaultTriangulation.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 Class for computing default triangulations of graphs
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_DEFAULT_TRIANGULATION_H
28 #define GUM_DEFAULT_TRIANGULATION_H
29 
30 #include <agrum/tools/graphs/algorithms/simplicialSet.h>
31 #include <agrum/tools/graphs/algorithms/triangulations/unconstrainedTriangulation.h>
32 
33 namespace gum {
34 
35  /** @class DefaultTriangulation
36  * @brief The default triangulation algorithm used by aGrUM
37  *
38  * \ingroup graph_group
39  *
40  * By default, this is the very class used by aGrUM for performing
41  * triangulations. The algorithm used is the following:
42  * # the graph passed in argument is completed by fill-ins until it becomes
43  * triangulated
44  * # then an elimination tree is computed from this triangulated graph
45  * # finally, a junction tree is derived from the elimination tree
46  *
47  * The triangulation step first tries to remove simplicial nodes, that is,
48  * nodes that belong to only one clique. Then almost simplicial nodes of low
49  * width are removed (almost simplicial nodes are nodes such that all but
50  * one of their neighbors form a clique). Then quasi simplicial nodes are
51  * removed, that is, nodes such that the ratio of the number of fill-ins to
52  * add to form a clique by the number of edges in a clique is small. Then
53  * nodes that create cliques of small weight are removed.
54  *
55  * The transformation from the elimination tree to the join tree is performed
56  * bottom-up. Each time a node of the elimination tree is identified to be a
57  * sub-clique, it is removed and all of its parents but one are linked to the
58  * latter. The identification of sub-cliques is very fast (comparison
59  * of 2 ints).
60  */
62  public:
63  // ############################################################################
64  /// @name Constructors / Destructors
65  // ############################################################################
66  /// @{
67 
68  /// basic constructor. initialize the triangulation
69  explicit DefaultTriangulation(const UndiGraph* graph,
70  const NodeProperty< Size >* dom_sizes,
71  bool minimality = false,
72  double theRatio = GUM_QUASI_RATIO,
73  double theThreshold = GUM_WEIGHT_THRESHOLD);
74 
75  /// default constructor: initialize the triangulation for an empty graph
76  explicit DefaultTriangulation(bool minimality = false,
77  double theRatio = GUM_QUASI_RATIO,
78  double theThreshold = GUM_WEIGHT_THRESHOLD);
79 
80  /// copy constructor
82 
83  /// move constructor
85 
86  /// destructor
88 
89  /// virtual clone constructor
90  /** returns a fresh triangulation (over an empty graph) of the same
91  * type as the current object
92  *
93  * note that we return a pointer as it enables subclasses to return
94  * pointers to their types, not Triangulation pointers. See item 25 of the
95  * more effective C++.*/
96  virtual DefaultTriangulation* newFactory() const;
97 
98  /// virtual copy constructor
99  virtual DefaultTriangulation* copyFactory() const;
100 
101  /// @}
102 
103 
104  private:
105  /// the ratio above which we consider nodes to be quasi simplicial
107 
108  /** @brief threshold under which almost and quasi simplicial nodes can be
109  * chosen to be eliminated */
110  double _threshold_;
111 
112 
113  // ############################################################################
114  /// @name Operators
115  // ############################################################################
116  /// @{
117 
118  /// forbid copy operator
120 
121  /// @}
122  };
123 
124 
125 } /* namespace gum */
126 
127 
128 #endif /* GUM_DEFAULT_TRIANGULATION_H */
virtual DefaultTriangulation * newFactory() const
virtual clone constructor
DefaultTriangulation(bool minimality=false, double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
default constructor: initialize the triangulation for an empty graph
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
DefaultTriangulation(const DefaultTriangulation &from)
copy constructor
double _threshold_
threshold under which almost and quasi simplicial nodes can be chosen to be eliminated ...
DefaultTriangulation(const UndiGraph *graph, const NodeProperty< Size > *dom_sizes, bool minimality=false, double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
basic constructor. initialize the triangulation
double _quasi_ratio_
the ratio above which we consider nodes to be quasi simplicial
~DefaultTriangulation()
destructor
DefaultTriangulation(DefaultTriangulation &&from)
move constructor
The default triangulation algorithm used by aGrUM.
virtual DefaultTriangulation * copyFactory() const
virtual copy constructor
DefaultTriangulation & operator=(const DefaultTriangulation &)
forbid copy operator