aGrUM  0.16.0
partialOrderedEliminationSequenceStrategy.cpp
Go to the documentation of this file.
1 
35 
36 #ifdef GUM_NO_INLINE
38 #endif // GUM_NOINLINE
39 
40 namespace gum {
41 
45  // for debugging purposes
47  }
48 
53  const NodeProperty< Size >* dom_sizes,
54  const List< NodeSet >* subsets) {
55  setGraph(graph, dom_sizes);
56  setPartialOrder(subsets);
57 
58  // for debugging purposes
60  }
61 
69  // for debugging purposes
71  }
72 
77  EliminationSequenceStrategy(std::move(from)),
79  _nodeset(std::move(from._nodeset)),
81  from._partial_order_needed = true;
82 
83  // for debugging purposes
85  }
86 
90  // for debugging purposes
92  }
93 
96  UndiGraph* graph, const NodeProperty< Size >* domain_sizes) {
97  if (EliminationSequenceStrategy::setGraph(graph, domain_sizes)) {
99  return true;
100  }
101  return false;
102  }
103 
106  const List< NodeSet >* subsets) const {
107  if ((_graph == nullptr) || (subsets == nullptr)) return true;
108 
109  // determine the set of nodes in the subsets that belong to the graph
110  NodeSet nodes_found(_graph->size() / 2);
111  for (const auto& nodes : *subsets) {
112  for (const auto node : nodes) {
113  if (_graph->existsNode(node)) { nodes_found.insert(node); }
114  }
115  }
116 
117  // check that the size of nodes_found is equal to that of the graph
118  return nodes_found.size() != _graph->size();
119  }
120 
123  const List< NodeSet >* subsets) {
124  // check that the partial order contains all the nodes of the graph
126 
127  if (!_partial_order_needed) {
128  _subsets = subsets;
129 
130  // initialize properly the set of nodes that can be currently eliminated:
131  // find the first subset that contains some node(s) of the graph
132  _nodeset.clear();
133  for (_subset_iter = _subsets->cbegin(); _subset_iter != _subsets->cend();
134  ++_subset_iter) {
135  for (const auto node : *_subset_iter) {
136  if (_graph->existsNode(node)) { _nodeset.insert(node); }
137  }
138  if (!_nodeset.empty()) return true;
139  }
140  }
141 
142  return false;
143  }
144 
148  _subsets = nullptr;
149  _nodeset.clear();
150  _partial_order_needed = true;
151  }
152 
153 } /* namespace gum */
virtual void clear()
clears the sequence (to prepare, for instance, a new elimination sequence)
virtual void clear()
clears the sequence (to prepare, for instance, a new elimination sequence)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:707
UndiGraph * _graph
the graph to be triangulated
bool _isPartialOrderNeeded(const List< NodeSet > *subsets) const
indicate whether a partial ordering is compatible with the current graph
Size size() const
alias for sizeNodes
virtual bool setPartialOrder(const List< NodeSet > *subsets)
sets a new partial ordering constraint on the elimination sequence
STL namespace.
Generic doubly linked lists.
Definition: list.h:372
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
UndiGraph * graph() const noexcept
returns the current graph
Base class for all elimination sequence algorithm that impose a given partial ordering on the nodes e...
PartialOrderedEliminationSequenceStrategy()
default constructor (uses an empty graph)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes)
sets a new graph to be triangulated
NodeSet _nodeset
the nodes which can be currently eliminated
const List< NodeSet > * _subsets
the subsets constituting the partial ordering
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
virtual bool setGraph(UndiGraph *graph, const NodeProperty< Size > *dom_sizes)
sets a new graph to be triangulated
The base class for all elimination sequence algorithms used by triangulation algorithms.
Base class for undirected graphs.
Definition: undiGraph.h:109
List< NodeSet >::const_iterator _subset_iter
the iterator indicating which is the current subset on which we work
bool _partial_order_needed
indicate whether a new partial ordering is necessary for the elimination
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613