aGrUM  0.16.0
simplicialSet.h
Go to the documentation of this file.
1 
29 #ifndef GUM_SIMPLICIAL_SET_H
30 #define GUM_SIMPLICIAL_SET_H
31 
32 #include <iostream>
33 #include <utility>
34 
35 #include <agrum/agrum.h>
36 
39 
40 #define GUM_QUASI_RATIO 0.99
41 #define GUM_WEIGHT_THRESHOLD 0.0
42 
43 namespace gum {
44 
45  /* ===========================================================================
46  */
47  /* === CLASS FOR RETRIEVING SIMPLICIAL, ALMOST AND QUASI SIMPLICIAL NODES ===
48  */
49  /* ===========================================================================
50  */
58  /* ===========================================================================
59  */
60  class SimplicialSet {
61  public:
62  // ############################################################################
64  // ############################################################################
66 
68 
105  explicit SimplicialSet(UndiGraph* graph,
106  const NodeProperty< double >* log_domain_sizes,
107  NodeProperty< double >* log_weights,
108  double theRatio = GUM_QUASI_RATIO,
109  double theThreshold = GUM_WEIGHT_THRESHOLD);
110 
112 
150  SimplicialSet(const SimplicialSet& simplicial_from,
151  UndiGraph* graph,
152  const NodeProperty< double >* log_domain_sizes,
153  NodeProperty< double >* log_weights,
154  bool avoid_check = false);
155 
158 
160  ~SimplicialSet();
161 
163 
164  // ############################################################################
166  // ############################################################################
168 
171 
172  void makeClique(const NodeId id);
173 
175 
180  void eraseClique(const NodeId id);
181 
183 
187  void eraseNode(const NodeId id);
188 
190 
193  void eraseEdge(const Edge& edge);
194 
196 
202  void addEdge(NodeId first, NodeId second);
203 
205 
208  bool isSimplicial(const NodeId id);
209 
211 
213  bool hasSimplicialNode();
214 
217 
219  bool hasQuasiSimplicialNode();
220 
222 
225 
227 
230 
233 
235 
238 
241 
243 
246 
248 
252  void setFillIns(bool on_off);
253 
255  const EdgeSet& fillIns() const;
256 
258 
284  void setGraph(UndiGraph* graph,
285  const NodeProperty< double >* log_domain_sizes,
286  NodeProperty< double >* log_weights,
287  double theRatio = GUM_QUASI_RATIO,
288  double theThreshold = GUM_WEIGHT_THRESHOLD);
289 
291 
294  void replaceLogWeights(NodeProperty< double >* old_weigths,
295  NodeProperty< double >* new_weights);
296 
298 
299 
300  private:
303 
306 
309 
312 
315 
318 
321  enum class __Belong : char {
322  SIMPLICIAL,
325  NO_LIST
326  };
328 
332 
335 
337 
345 
350 
354 
357 
360  bool __we_want_fill_ins{false};
361 
364 
365 
368  void __updateList(const NodeId id);
369 
371  void __updateAllNodes();
372 
379  void __initialize();
380 
382 
388 
390 
395  };
396 
397 } /* namespace gum */
398 
399 #ifndef GUM_NO_INLINE
401 #endif /* GUM_NO_INLINE */
402 
403 #endif /* GUM_SIMPLICIAL_SET_H */
void makeClique(const NodeId id)
adds the necessary edges so that node &#39;id&#39; and its neighbors form a clique
void __initialize()
initialize: compute __nb_triangles, __nb_adjacent_neighbors, etc when a new graph is set ...
NodeId bestQuasiSimplicialNode()
gets a quasi simplicial node with the lowest clique weight
void eraseNode(const NodeId id)
removes a node and its adjacent edges from the underlying graph
NodeProperty< __Belong > __containing_list
#define GUM_WEIGHT_THRESHOLD
Definition: simplicialSet.h:41
void setGraph(UndiGraph *graph, const NodeProperty< double > *log_domain_sizes, NodeProperty< double > *log_weights, double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
initialize the simplicial set w.r.t. a new graph
bool hasQuasiSimplicialNode()
indicates whether there exists a quasi simplicial node
void replaceLogWeights(NodeProperty< double > *old_weigths, NodeProperty< double > *new_weights)
reassigns a new set of cliques&#39; log weights (with the same content)
bool hasAlmostSimplicialNode()
indicates whether there exists an almost simplicial node
void eraseClique(const NodeId id)
removes a node and its adjacent edges from the underlying graph
double __log_threshold
quasi and almost simplicial nodes may not be eliminated unless their weight is lower than (1 + thresh...
NodeProperty< Size > __nb_adjacent_neighbours
for each node, the number of pairs of adjacent neighbours
UndiGraph * __graph
the graph on which we perform the simplicial computations
void __updateAllNodes()
put all the nodes in their appropriate list
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
__Belong
indicates for each node to which list (simplicial, almost simplicial, quasi simplicial) it belongs ...
NodeProperty< double > * __log_weights
the weights of the nodes (i.e., weight of their clique)
double __log_tree_width
the current (induced) tree width
The class for generic Hash Tables.
Definition: hashTable.h:679
void __updateList(const NodeId id)
put node id in the correct simplicial/almost simplicial/quasi simplicial list
NodeSet __changed_status
the set of nodes that have potentially changed of status
const PriorityQueue< NodeId, double > & allSimplicialNodes()
returns all the simplicial nodes
double __quasi_ratio
for a given node, if the number of pairs of neighbors that are adjacent / the number of adjacent neig...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
EdgeProperty< Size > __nb_triangles
for each edge, keep track of the number of triangles passing through this egde
Class enabling fast retrieval of simplicial, quasi and almost simplicial nodes.
Definition: simplicialSet.h:60
PriorityQueue< NodeId, double > __simplicial_nodes
a queue of the simplicial nodes ordered by increasing node weight
void addEdge(NodeId first, NodeId second)
adds a new edge to the graph and recomputes the simplicial set
PriorityQueue< NodeId, double > __quasi_simplicial_nodes
a queue of the quasi simplicial nodes ordered by increasing node weight
bool hasSimplicialNode()
indicates whether there exists a simplicial node
EdgeSet __fill_ins_list
fill-ins list
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
SimplicialSet(UndiGraph *graph, const NodeProperty< double > *log_domain_sizes, NodeProperty< double > *log_weights, double theRatio=GUM_QUASI_RATIO, double theThreshold=GUM_WEIGHT_THRESHOLD)
constructor. initializes the simplicial set w.r.t. a given graph
bool isSimplicial(const NodeId id)
indicates whether a given node is a simplicial node
The base class for all undirected edges.
NodeId bestAlmostSimplicialNode()
gets the almost simplicial node with the lowest clique weight
SimplicialSet & operator=(const SimplicialSet &)
prevent a copy operator to be used
Base class for undirected graphs.
Definition: undiGraph.h:109
NodeId bestSimplicialNode()
returns the simplicial node with the lowest clique weight
const PriorityQueue< NodeId, double > & allAlmostSimplicialNodes()
returns all the almost simplicial nodes
PriorityQueue< NodeId, double > __almost_simplicial_nodes
a queue of the almost simplicial nodes ordered by increasing node weight
#define GUM_QUASI_RATIO
Definition: simplicialSet.h:40
bool __we_want_fill_ins
a boolean indicating if we want fill-ins list with the standard triangulation method ...
~SimplicialSet()
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const PriorityQueue< NodeId, double > & allQuasiSimplicialNodes()
returns all the quasi simplicial nodes
const NodeProperty< double > * __log_domain_sizes
the log of the modalities of the nodes
void setFillIns(bool on_off)
sets/unset the fill-ins storage in the standard triangulation procedure
Size NodeId
Type for node ids.
Definition: graphElements.h:98
const EdgeSet & fillIns() const
returns the set of all the fill-ins added to the graph so far
void eraseEdge(const Edge &edge)
removes an edge from the graph and recomputes the simplicial set