aGrUM  0.14.2
staticTriangulation.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
25 #ifndef GUM_STATIC_TRIANGULATION_H
26 #define GUM_STATIC_TRIANGULATION_H
27 
28 #include <vector>
29 
30 #include <agrum/agrum.h>
31 
36 
37 
38 namespace gum {
39 
40 
48  public:
49  // ############################################################################
51  // ############################################################################
53 
60  virtual StaticTriangulation* newFactory() const = 0;
61 
63 
66  virtual StaticTriangulation* copyFactory() const = 0;
67 
69  virtual ~StaticTriangulation();
70 
72 
73 
74  // ############################################################################
76  // ############################################################################
78 
80 
88  virtual void setGraph(const UndiGraph* graph,
89  const NodeProperty< Size >* domsizes);
90 
92  const EdgeSet& fillIns();
93 
95  const std::vector< NodeId >& eliminationOrder();
96 
100 
104 
106  const UndiGraph& triangulatedGraph();
107 
109  const CliqueGraph& eliminationTree();
110 
112  const CliqueGraph& junctionTree();
113 
117 
121 
123 
130 
134 
136  void clear();
137 
139  void setMinimalRequirement(bool);
140 
142  virtual bool isMinimalityRequired() const final;
143 
146  void setFillIns(bool);
147 
149 
151  const UndiGraph* originalGraph() const;
152 
155 
158 
160 
161 
162  protected:
163  // ############################################################################
165  // ############################################################################
167 
169 
175  const JunctionTreeStrategy& JTStrategy,
176  bool minimality = false);
177 
179 
192  StaticTriangulation(const UndiGraph* graph,
193  const NodeProperty< Size >* dom_sizes,
194  const EliminationSequenceStrategy& elimSeq,
195  const JunctionTreeStrategy& JTStrategy,
196  bool minimality = false);
197 
200 
203 
205 
206 
207  // ############################################################################
209  // ############################################################################
211 
213 
222  virtual void _initTriangulation(UndiGraph& graph);
223 
225 
226 
229 
232 
233 
234  private:
236  const UndiGraph* __original_graph{nullptr};
237 
240 
243 
245  std::vector< NodeId > __elim_order;
246 
249 
252 
255 
257 
260  const CliqueGraph* __junction_tree{nullptr};
261 
264 
268 
270  bool __has_triangulation{false};
271 
274 
277 
279  bool __has_junction_tree{false};
280 
284 
286  bool __has_fill_ins{false};
287 
290 
293  std::vector< EdgeSet > __added_fill_ins;
294 
297  bool __we_want_fill_ins{false};
298 
299  // ===========================================================================
300 
302  void __triangulate();
303 
306 
309 
313 
315  void __computeMaxPrimeMergings(const NodeId node,
316  const NodeId from,
317  std::vector< Arc >& merged_cliques,
318  NodeSet& mark) const;
319 
322  };
323 
324 } /* namespace gum */
325 
326 #ifndef GUM_NO_INLINE
328 #endif // GUM_NO_INLINE
329 
330 #endif /* GUM_STATIC_TRIANGULATION_H */
const CliqueGraph & junctionTree()
returns a compatible junction tree
const UndiGraph & triangulatedGraph()
returns the triangulated graph
const UndiGraph * originalGraph() const
returns the graph to be triangulated
void clear()
reinitialize the graph to be triangulated to an empty graph
void setMinimalRequirement(bool)
sets/unset the minimality requirement
virtual bool isMinimalityRequired() const final
indicates wether minimality is required
NodeProperty< NodeId > __node_2_max_prime_clique
indicates which clique of the max prime junction tree was created by the elmination of a given node (...
void __triangulate()
the function that performs the triangulation
bool __has_max_prime_junction_tree
indicates whether a maximal prime subgraph junction tree has been constructed
virtual ~StaticTriangulation()
destructor
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const UndiGraph * __original_graph
a pointer to the (external) original graph (which will be triangulated)
virtual void _initTriangulation(UndiGraph &graph)
the function called to initialize the triangulation process
const EdgeSet & fillIns()
returns the fill-ins added by the triangulation algorithm
void __computeMaxPrimeJunctionTree()
computes the junction tree of the maximal prime subgraphs
bool __has_triangulated_graph
a boolean indicating whether we have constructed the triangulated graph
JunctionTreeStrategy * _junction_tree_strategy
the junction tree strategy used by the triangulation
UndiGraph __triangulated_graph
the triangulated graph
NodeId createdMaxPrimeSubgraph(const NodeId id)
returns the Id of the maximal prime subgraph created by the elimination of a given node during the tr...
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
NodeProperty< NodeId > __reverse_elim_order
the elimination order (access by NodeId)
std::vector< EdgeSet > __added_fill_ins
a vector containing the set of fill-ins added after each node elimination (used by recursive thinning...
The class for generic Hash Tables.
Definition: hashTable.h:676
JunctionTreeStrategy & junctionTreeStrategy() const
returns the junction tree strategy used by the triangulation
bool __has_triangulation
a boolean indicating whether we have parformed a triangulation
const CliqueGraph & eliminationTree()
returns the elimination tree of a compatible ordering
bool __has_junction_tree
a boolean indicating whether the junction tree has been constructed
Abstract base class for computing triangulations of graphs.
void setFillIns(bool)
sets/unsets the record of the fill-ins in the standard triangulation procedure
const NodeProperty< NodeId > & reverseEliminationOrder()
returns a table indicating, for each node, at which step it was deleted by the triangulation process ...
CliqueGraph __max_prime_junction_tree
the maximal prime subgraph junction tree computed from the junction tree
const std::vector< NodeId > & eliminationOrder()
returns an elimination ordering compatible with the triangulated graph
Base Class for all the algorithms producing a junction given a set of cliques/subcliques resulting fr...
Base Class for all the algorithms producing a junction given a set of cliques/subcliques resulting fr...
NodeProperty< NodeSet > __elim_cliques
the cliques formed by the elimination of the nodes
Basic graph of cliques.
Definition: cliqueGraph.h:55
Base Class for all elimination sequence algorithms used by triangulations.
virtual StaticTriangulation * copyFactory() const =0
virtual copy constructor
virtual StaticTriangulation * newFactory() const =0
returns a fresh triangulation of the same type as the current object but over an empty graph ...
EliminationSequenceStrategy & eliminationSequenceStrategy() const
returns the elimination sequence strategy used by the triangulation
const NodeProperty< NodeId > & createdJunctionTreeCliques()
returns the Ids of the cliques of the junction tree created by the elimination of the nodes ...
The base class for all elimination sequence algorithms used by triangulation algorithms.
bool __we_want_fill_ins
a boolean indicating if we want fill-ins list with the standard triangulation method ...
bool __has_fill_ins
indicates whether we actually computed fill-ins
bool __minimality_required
indicates whether the triangulation must be minimal
base class for all non-incremental triangulation methods
const CliqueGraph * __junction_tree
the junction tree computed by the algorithm
void __computeEliminationTree()
returns an elimination tree from a triangulated graph
Base class for undirected graphs.
Definition: undiGraph.h:106
Size Idx
Type for indexes.
Definition: types.h:50
bool __has_elimination_tree
a boolean indicating whether the elimination tree has been computed
virtual void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes)
initialize the triangulation data structures for a new graph
void __computeMaxPrimeMergings(const NodeId node, const NodeId from, std::vector< Arc > &merged_cliques, NodeSet &mark) const
used for computing the junction tree of the maximal prime subgraphs
EdgeSet __fill_ins
the fill-ins added during the whole triangulation process
Interface for all the triangulation methods.
Definition: triangulation.h:44
Basic class for all graphs of cliques (join trees, etc)
void __computeRecursiveThinning()
removes redondant fill-ins and compute proper elimination cliques and order
StaticTriangulation & operator=(const StaticTriangulation &)
forbid copy operator
std::vector< NodeId > __elim_order
the order in which nodes are eliminated by the algorithm
const CliqueGraph & maxPrimeSubgraphTree()
returns a junction tree of maximal prime subgraphs
Size NodeId
Type for node ids.
Definition: graphElements.h:97
NodeId createdJunctionTreeClique(const NodeId id)
returns the Id of the clique of the junction tree created by the elimination of a given node during t...
CliqueGraph __elim_tree
the elimination tree computed by the algorithm
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph
Inline implementations for computing default triangulations of graphs.