54 std::vector< NodeId > nodes_to_inspect;
61 nodes_to_inspect.push_back(root);
63 while (!nodes_to_inspect.empty()) {
65 NodeId current_node = nodes_to_inspect.back();
66 nodes_to_inspect.pop_back();
71 if (!mark[current_node]) {
72 mark[current_node] =
true;
75 for (
const auto neigh : JT.
neighbours(current_node))
76 if (!mark[neigh]) nodes_to_inspect.push_back(neigh);
88 for (
const auto node : nodes1)
89 result *= domain_sizes[node];
91 for (
const auto node : nodes2)
92 if (!nodes1.exists(node)) result *= domain_sizes[node];
110 if (neighbors.
size() <= 2)
return;
112 if ((neighbors.
size() == 3) && (clique != from))
return;
116 std::vector< NodeId > cliques;
117 cliques.reserve(neighbors.
size());
119 for (
const auto nei : neighbors)
120 if (nei != from) cliques.push_back(nei);
126 std::vector< bool > is_cliques_relevant(cliques.size(),
true);
132 std::pair< NodeId, NodeId > pair;
136 for (
NodeId i = 0; i < cliques.size(); ++i) {
140 for (
NodeId j = i + 1; j < cliques.size(); ++j) {
153 for (
NodeId k = 2; k < cliques.size(); ++k) {
164 JT.
addEdge(cliques[ti], new_node);
165 JT.
addEdge(cliques[tj], new_node);
171 cliques[ti] = new_node;
172 is_cliques_relevant[tj] =
false;
176 for (
NodeId ind = 0; ind < tj; ++ind) {
177 if (is_cliques_relevant[ind]) {
185 for (
NodeId ind = tj + 1; ind < cliques.size(); ++ind) {
186 if (is_cliques_relevant[ind]) {
198 for (
NodeId ind = 0; ind < ti; ++ind) {
199 if (is_cliques_relevant[ind]) {
202 nodes1, JT.
separator(cliques[ind], clique), domain_sizes);
209 for (
NodeId ind = ti + 1; ind < cliques.size(); ++ind) {
210 if (is_cliques_relevant[ind]) {
213 nodes1, JT.
separator(cliques[ind], clique), domain_sizes);
230 mark[current_node] =
true;
233 for (
const auto neigh : JT.
neighbours(current_node)) {
247 const NodeSet& specified_roots) {
260 for (
const auto root : specified_roots) {
266 "several roots have been specified for a given " 267 "connected component");
274 for (
const auto& elt : mark)
286 for (
const auto root :
__roots)
NodeId addNode(const NodeSet &clique)
adds a new clique to the graph
Val pop()
Removes the top element from the priority queue and return it.
BinaryJoinTreeConverterDefault()
default constructor
CliqueGraph convert(const CliqueGraph &JT, const NodeProperty< Size > &domain_sizes, const NodeSet &roots)
returns a binary join tree corresponding to clique graph JT
const NodeSet & separator(const Edge &edge) const
returns the separator included in a given edge
NodeProperty< VAL > nodesProperty(VAL(*f)(const NodeId &), Size size=0) const
a method to create a HashTable with key:NodeId and value:VAL
void __markConnectedComponent(const CliqueGraph &JT, NodeId root, NodeProperty< bool > &mark) const
a function used to mark the nodes belonging to a given connected component
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
void erase(const Val &val)
Removes a given element from the priority queue (but does not return it).
const NodeSet & neighbours(const NodeId id) const
returns the set of edges adjacent to a given node
void setPriority(const Val &elt, const Priority &new_priority)
Modifies the priority of each instance of a given element.
const NodeSet & roots() const
returns all the roots considered for all the connected components
A priorityQueue is a heap in which each element has a mutable priorityA priority queue is quite simil...
void __convertClique(CliqueGraph &JT, NodeId clique, NodeId from, const NodeProperty< Size > &domain_sizes) const
convert a clique and its adjacent cliques into a binary join tree
virtual ~BinaryJoinTreeConverterDefault()
destructor
virtual void eraseEdge(const Edge &edge)
removes an edge (and its separator) from the clique graph
void __convertConnectedComponent(CliqueGraph &JT, NodeId current_node, NodeId from, const NodeProperty< Size > &domain_sizes, NodeProperty< bool > &mark) const
convert a whole connected component into a binary join tree
virtual void addEdge(const NodeId first, const NodeId second)
inserts a new edge between two cliques
Size insert(const Val &val, const Priority &priority)
Inserts a new (a copy) element in the priority queue.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
The base class for all undirected edges.
NodeSet __roots
the new roots that have been created to compute the last query
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size size() const noexcept
Returns the number of elements in the set.
float __combinedSize(const NodeSet &nodes1, const NodeSet &nodes2, const NodeProperty< Size > &domain_sizes) const
returns the domain size of the union of two cliques
Size NodeId
Type for node ids.
#define GUM_ERROR(type, msg)