73 if (theGraph !=
nullptr) {
119 _junction_tree_ = &(junction_tree_strategy_->junctionTree());
152 if (from._junction_tree_ !=
nullptr) {
153 _junction_tree_ = &(junction_tree_strategy_->junctionTree());
208 std::vector< NodeId > adj;
232 bool require_mint =
true;
234 for (
unsigned int j = 0; require_mint; ++j) {
239 for (
const auto& edge: T) {
240 node1 = edge.first();
241 node2 = edge.second();
244 if ((R[node1] < j) && (R[node2] < j))
continue;
263 for (
unsigned int k = 0; k < adj.size() && !incomplete; ++k) {
264 for (
unsigned int m = k + 1; m < adj.size(); ++m) {
283 for (
const auto& edge: T_prime) {
290 if (T_prime.size() == 0) require_mint =
false;
307 std::greater< unsigned int >(),
352 for (
auto i =
NodeId(0); i < size; ++i)
357 for (
auto i =
NodeId(0); i < size; ++i) {
362 for (
const auto node: list_of_nodes) {
365 if ((node != clique_i_creator) && (child > it_elim_step)) child = it_elim_step;
368 if (child <= _original_graph_->bound()) {
381 std::vector< Arc >& merged_cliques,
386 if (other_node != from) {
389 bool complete =
true;
391 for (
auto iter_sep1 = separator.
begin(); iter_sep1 != separator.
end() && complete;
393 auto iter_sep2 = iter_sep1;
395 for (++iter_sep2; iter_sep2 != separator.
end(); ++iter_sep2) {
404 if (!complete) merged_cliques.push_back(
Arc(other_node, node));
428 T_mpd_cliques.
insert(clik, clik);
432 std::vector< Arc > merged_cliques;
442 for (
unsigned int i = 0; i < merged_cliques.size(); ++i) {
443 T_mpd_cliques[merged_cliques[i].tail()] = T_mpd_cliques[merged_cliques[i].head()];
447 for (
const auto& elt: T_mpd_cliques)
448 if (elt.first == elt.second)
453 for (
const auto& elt: T_mpd_cliques)
454 if (elt.first != elt.second)
463 NodeId node1 = T_mpd_cliques[edge.first()];
464 NodeId node2 = T_mpd_cliques[edge.second()];
466 if (node1 != node2) {
478 for (
const auto& elt: node_2_junction_clique)
500 std::vector< NodeId > clique_nodes(clique.
size());
503 for (
const auto node: clique) {
504 clique_nodes[i] = node;
508 for (i = 0; i < clique_nodes.size(); ++i) {
509 for (
unsigned int j = i + 1; j < clique_nodes.size(); ++j) {
528 if (graph !=
nullptr) {
570 NodeId removable_node = 0;
572 for (
unsigned int nb_elim = 0; tmp_graph.
size() != 0; ++nb_elim) {
580 cliques << removable_node;
581 for (
const auto clik: tmp_graph.
neighbours(removable_node))
591 for (
auto iter_edges1 = nei.
begin(); iter_edges1 != nei.
end(); ++iter_edges1) {
592 node1 = *iter_edges1;
593 auto iter_edges2 = iter_edges1;
595 for (++iter_edges2; iter_edges2 != nei.
end(); ++iter_edges2) {
596 node2 = *iter_edges2;
597 Edge edge(node1, node2);
600 current_fill.
insert(edge);
616 for (
auto iter_edges1 = nei.
begin(); iter_edges1 != nei.
end(); ++iter_edges1) {
617 node1 = *iter_edges1;
618 auto iter_edges2 = iter_edges1;
620 for (++iter_edges2; iter_edges2 != nei.
end(); ++iter_edges2) {
621 node2 = *iter_edges2;
622 Edge edge(node1, node2);
642 for (
auto iter_edges1 = nei.
begin(); iter_edges1 != nei.
end(); ++iter_edges1) {
643 node1 = *iter_edges1;
644 auto iter_edges2 = iter_edges1;
646 for (++iter_edges2; iter_edges2 != nei.
end(); ++iter_edges2) {
647 node2 = *iter_edges2;
648 Edge edge(node1, node2);
699 std::vector< NodeId > clique_nodes(clique.
size());
702 for (
const auto node: clique) {
703 clique_nodes[i] = node;
707 for (i = 0; i < clique_nodes.size(); ++i) {
708 for (
unsigned int j = i + 1; j < clique_nodes.size(); ++j) {
709 Edge edge(clique_nodes[i], clique_nodes[j]);
The base class for all directed edges.
An efficient unconstrained elimination sequence algorithm.
An algorithm producing a junction given the elimination tree produced by a triangulation algorithm.
Exception : a similar element already exists.
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
The base class for all undirected edges.
The base class for all elimination sequence algorithms used by triangulation algorithms.
virtual EliminationSequenceStrategy * copyFactory() const =0
virtual copy constructor
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Base Class for all the algorithms producing a junction given a set of cliques/subcliques resulting fr...
virtual JunctionTreeStrategy * copyFactory(StaticTriangulation *triangulation=nullptr) const =0
virtual copy constructor
Size size() const
alias for sizeNodes
Exception : the element we looked for cannot be found.
void setPriority(const Val &elt, const Priority &new_priority)
Modifies the priority of each instance of a given element.
Val pop()
Removes the top element from the priority queue and return it.
const Priority & priority(const Val &elt) const
Returns the priority of an instance of the value passed in argument.
Size insert(const Val &val, const Priority &priority)
Inserts a new (a copy) element in the priority queue.
A priorityQueue is a heap in which each element has a mutable priority.
iterator begin() const
The usual unsafe begin iterator to parse the set.
const iterator & end() const noexcept
The usual unsafe end iterator to parse the set.
Size size() const noexcept
Returns the number of elements in the set.
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
void resize(Size new_capacity)
Changes the size of the underlying hash table containing the set.
void insert(const Key &k)
Inserts a new element into the set.
bool _has_junction_tree_
a boolean indicating whether the junction tree has been constructed
NodeProperty< NodeId > _reverse_elim_order_
the elimination order (access by NodeId)
JunctionTreeStrategy * junction_tree_strategy_
the junction tree strategy used by the triangulation
bool _has_fill_ins_
indicates whether we actually computed fill-ins
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
void _computeMaxPrimeJunctionTree_()
computes the junction tree of the maximal prime subgraphs
const EdgeSet & fillIns()
returns the fill-ins added by the triangulation algorithm
void _computeEliminationTree_()
returns an elimination tree from a triangulated graph
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph
const CliqueGraph & junctionTree()
returns a compatible junction tree
bool _has_triangulation_
a boolean indicating whether we have parformed a triangulation
virtual void initTriangulation_(UndiGraph &graph)
the function called to initialize the triangulation process
NodeProperty< NodeSet > _elim_cliques_
the cliques formed by the elimination of the nodes
bool _we_want_fill_ins_
a boolean indicating if we want fill-ins list with the standard triangulation method
EliminationSequenceStrategy * elimination_sequence_strategy_
the elimination sequence strategy used by the triangulation
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 (...
CliqueGraph _max_prime_junction_tree_
the maximal prime subgraph junction tree computed from the junction tree
const UndiGraph * _original_graph_
a pointer to the (external) original graph (which will be triangulated)
void clear()
reinitialize the graph to be triangulated to an empty graph
UndiGraph _triangulated_graph_
the triangulated graph
void _computeRecursiveThinning_()
removes redondant fill-ins and compute proper elimination cliques and order
std::vector< EdgeSet > _added_fill_ins_
a vector containing the set of fill-ins added after each node elimination (used by recursive thinning...
bool _has_elimination_tree_
a boolean indicating whether the elimination tree has been computed
bool _minimality_required_
indicates whether the triangulation must be minimal
virtual StaticTriangulation * newFactory() const =0
returns a fresh triangulation of the same type as the current object but over an empty graph
virtual void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes)
initialize the triangulation data structures for a new graph
EdgeSet _fill_ins_
the fill-ins added during the whole triangulation process
virtual ~StaticTriangulation()
destructor
void _triangulate_()
the function that performs the triangulation
const UndiGraph & triangulatedGraph()
returns the triangulated graph
std::vector< NodeId > _elim_order_
the order in which nodes are eliminated by the algorithm
CliqueGraph _elim_tree_
the elimination tree computed by the algorithm
bool _has_max_prime_junction_tree_
indicates whether a maximal prime subgraph junction tree has been constructed
const CliqueGraph * _junction_tree_
the junction tree computed by the algorithm
bool _has_triangulated_graph_
a boolean indicating whether we have constructed the triangulated graph
const NodeProperty< Size > * domain_sizes_
the domain sizes of the variables/nodes of the graph
Triangulation()
default constructor
Base class for undirected graphs.
void addEdge(NodeId first, NodeId second) override
insert a new edge into the undirected graph
void eraseNode(NodeId id) override
remove a node and its adjacent edges from the graph
An efficient unconstrained elimination sequence algorithm.
An algorithms producing a junction given the elimination tree produced by the triangulation algorithm...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
priority queues (in which an element cannot appear more than once)
base class for all non-incremental triangulations.
Inline implementations for computing default triangulations of graphs.