aGrUM  0.14.2
incrementalTriangulation.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  ***************************************************************************/
20 
27 #ifndef GUM_INCREMENTAL_TRIANGULATION_H
28 #define GUM_INCREMENTAL_TRIANGULATION_H
29 
30 #include <iostream>
31 #include <sstream>
32 #include <vector>
33 
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 namespace gum_tests {
40  class IncrementalTriangulationTestSuite;
41 }
42 #endif
43 
44 namespace gum {
45 
50  public:
51  // ############################################################################
53  // ############################################################################
55 
57 
62  const UndiGraph* theGraph,
63  const NodeProperty< Size >* modal);
64 
67 
70 
73 
75 
76 
77  // ############################################################################
79  // ############################################################################
81 
83  void updateTriangulation();
84 
86  void addNode(const NodeId node, Size modal);
87 
90  void eraseNode(const NodeId node);
91 
94  void addEdge(const NodeId X, const NodeId Y);
95 
98  void eraseEdge(const Edge& edge);
99 
101  const EdgeSet& fillIns() {
102  GUM_ERROR(OperationNotAllowed, "Not implemented yet");
103  };
104 
106 
108  const std::vector< NodeId >& eliminationOrder();
109 
112  Idx eliminationOrder(const NodeId);
113 
116  GUM_ERROR(OperationNotAllowed, "Not implemented yet");
117  };
118 
120  const UndiGraph& graph() const;
121 
124  GUM_ERROR(OperationNotAllowed, "Not implemented yet");
125  };
126 
128  const CliqueGraph& junctionTree();
129 
132  NodeId createdJunctionTreeClique(const NodeId id);
133 
136  const NodeProperty< NodeId >& createdJunctionTreeCliques();
137 
139  const CliqueGraph& maxPrimeSubgraphTree();
140 
143  NodeId createdMaxPrimeSubgraph(const NodeId id);
144 
146  void clear();
147 
149  void setGraph(const UndiGraph* theGraph,
150  const NodeProperty< Size >* domain_sizes);
151 
153  const UnconstrainedTriangulation& triangulationAlgo() const;
154 
156 
157 
158  // ############################################################################
160  // ############################################################################
162 
164  IncrementalTriangulation& operator=(const IncrementalTriangulation& from);
165 
167  virtual IncrementalTriangulation* newFactory() const final;
168 
170  virtual IncrementalTriangulation* copyFactory() const final;
171 
173 
174 
175  private:
178 
181 
184 
187 
190 
193 
196 
199 
202 
204  bool __require_update{false};
205 
207  bool __require_elimination_order{false};
208 
210  std::vector< NodeId > __elimination_order;
211 
214 
216  bool __require_created_JT_cliques{false};
217 
220 
222  void __markAffectedMPSsByRemoveLink(const NodeId My,
223  const NodeId Mz,
224  const Edge& edge);
225 
227  int __markAffectedMPSsByAddLink(const NodeId My,
228  const NodeId Mz,
229  const NodeId X,
230  const NodeId Y);
231 
233  void __performRemoveNode(const NodeId node, const NodeId My, const NodeId Mz);
234 
236  void __performAddNode(const NodeId node);
237 
239  void __setUpConnectedTriangulation(
240  NodeId Mx,
241  NodeId Mfrom,
242  UndiGraph& theGraph,
243  std::vector< Edge >& notAffectedneighborClique,
244  HashTable< NodeId, bool >& cliques_affected);
245 
247  void __computeMaxPrimeMergings(
248  const NodeId node,
249  const NodeId from,
250  std::vector< std::pair< NodeId, NodeId > >& merged_cliques,
251  NodeProperty< bool >& mark,
252  const NodeSet& new_nodes_in_junction_tree) const;
253 
255  void __updateJunctionTree(NodeProperty< bool >& all_cliques_affected,
256  NodeSet& new_nodes_in_junction_tree);
257 
259  void __updateMaxPrimeSubgraph(NodeProperty< bool >& cliques_affected,
260  const NodeSet& new_nodes_in_junction_tree);
261 
263  void __collectEliminationOrder(const NodeId node,
264  const NodeId from,
265  NodeProperty< bool >& examined,
266  Idx& index);
267 
269  void __collectJTCliques(const NodeId clique,
270  const NodeId from,
271  NodeProperty< bool >& examined);
272 
274  bool __check();
275 
277  friend class gum_tests::IncrementalTriangulationTestSuite;
278  };
279 
280 } /* namespace gum */
281 
282 #ifndef GUM_NO_INLINE
284 #endif // GUM_NO_INLINE
285 
286 #endif /* GUM_INCREMENTAL_TRIANGULATION_H */
Inline implementations for computing default triangulations of graphs.
NodeProperty< std::vector< NodeId > > __cliques_of_mps
indicate for each MPS its set of cliques in the junction tree
const CliqueGraph & eliminationTree()
returns the elimination tree of a compatible ordering
CliqueGraph __T_mpd
the maximal prime subgraph tree
std::vector< NodeId > __elimination_order
the current elimination ordering
Interface for all triangulation methods without constraints on node elimination orderings.
base class for graph triangulations without constraints on nodes elimination ordering.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
NodeProperty< Size > __domain_sizes
the domain sizes of the nodes
UnconstrainedTriangulation * __triangulation
the triangulation algorithm that will be used incremantally
The class for generic Hash Tables.
Definition: hashTable.h:676
Class that performs incremental triangulations.
NodeProperty< NodeId > __mps_of_clique
indicate for each clique the MPS it belongs to
const UndiGraph & triangulatedGraph()
returns the triangulated graph
Basic graph of cliques.
Definition: cliqueGraph.h:55
The base class for all undirected edges.
CliqueGraph __junction_tree
the junction tree computed so far
Base class for undirected graphs.
Definition: undiGraph.h:106
Size Idx
Type for indexes.
Definition: types.h:50
NodeProperty< NodeId > __created_JT_cliques
For each node, a clique that contains it.
const EdgeSet & fillIns()
returns the fill-ins added by the triangulation algorithm
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
UndiGraph __graph
the graph that needs be triangulated
NodeProperty< List< NodeId > > __mps_of_node
for each node in graph, store the MPS containing the node
NodeProperty< Idx > __reverse_elimination_order
the elimination order (access by NodeId)
Interface for all the triangulation methods.
Definition: triangulation.h:44
Basic class for all graphs of cliques (join trees, etc)
Size NodeId
Type for node ids.
Definition: graphElements.h:97
NodeProperty< bool > __mps_affected
the set of MPS affected by a new triangulation
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
some utils for topology : NodeId, Edge, Arc and consorts ...