aGrUM  0.16.0
gum::OrderedTriangulation Class Reference

class for graph triangulations for which we enforce a given complete ordering on the nodes eliminations. More...

#include <orderedTriangulation.h>

+ Inheritance diagram for gum::OrderedTriangulation:
+ Collaboration diagram for gum::OrderedTriangulation:

Public Member Functions

Constructors / Destructors
 OrderedTriangulation (const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
 default constructor More...
 
 OrderedTriangulation (const UndiGraph *graph, const NodeProperty< Size > *domsizes, const std::vector< NodeId > *sequence, const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
 constructor with a given graph More...
 
 OrderedTriangulation (const OrderedTriangulation &from)
 copy constructor More...
 
 OrderedTriangulation (OrderedTriangulation &&from)
 move constructor More...
 
virtual OrderedTriangulationnewFactory () const final
 returns a fresh triangulation over the same graph and of the same type as the current object (using the same sequence, etc.) More...
 
virtual OrderedTriangulationcopyFactory () const final
 virtual copy constructor More...
 
virtual ~OrderedTriangulation ()
 destructor More...
 
Accessors / Modifiers
virtual void setGraph (const UndiGraph *graph, const NodeProperty< Size > *domsizes) final
 initialize the triangulation data structures for a new graph More...
 
virtual void setOrder (const std::vector< NodeId > *order) final
 sets the sequence of elimination (only the reference is stored) More...
 
Accessors / Modifiers
const EdgeSetfillIns ()
 returns the fill-ins added by the triangulation algorithm More...
 
const std::vector< NodeId > & eliminationOrder ()
 returns an elimination ordering compatible with the triangulated graph More...
 
Idx eliminationOrder (const NodeId)
 returns the index of a given node in the elimination order (0 = first node eliminated) More...
 
const NodeProperty< NodeId > & reverseEliminationOrder ()
 returns a table indicating, for each node, at which step it was deleted by the triangulation process More...
 
const UndiGraphtriangulatedGraph ()
 returns the triangulated graph More...
 
const CliqueGrapheliminationTree ()
 returns the elimination tree of a compatible ordering More...
 
const CliqueGraphjunctionTree ()
 returns a compatible junction tree More...
 
NodeId createdJunctionTreeClique (const NodeId id)
 returns the Id of the clique of the junction tree created by the elimination of a given node during the triangulation process More...
 
const NodeProperty< NodeId > & createdJunctionTreeCliques ()
 returns the Ids of the cliques of the junction tree created by the elimination of the nodes More...
 
const CliqueGraphmaxPrimeSubgraphTree ()
 returns a junction tree of maximal prime subgraphs More...
 
NodeId createdMaxPrimeSubgraph (const NodeId id)
 returns the Id of the maximal prime subgraph created by the elimination of a given node during the triangulation process More...
 
void clear ()
 reinitialize the graph to be triangulated to an empty graph More...
 
void setMinimalRequirement (bool)
 sets/unset the minimality requirement More...
 
virtual bool isMinimalityRequired () const final
 indicates wether minimality is required More...
 
void setFillIns (bool)
 sets/unsets the record of the fill-ins in the standard triangulation procedure More...
 
const UndiGraphoriginalGraph () const
 returns the graph to be triangulated More...
 
EliminationSequenceStrategyeliminationSequenceStrategy () const
 returns the elimination sequence strategy used by the triangulation More...
 
JunctionTreeStrategyjunctionTreeStrategy () const
 returns the junction tree strategy used by the triangulation More...
 
Accessors / Modifiers
double maxLog10CliqueDomainSize ()
 returns the max of log10DomainSize of the cliques in the junction tree. More...
 
const NodeProperty< Size > * domainSizes () const
 returns the domain sizes of the variables of the graph to be triangulated More...
 

Protected Attributes

const std::vector< NodeId > * __order {nullptr}
 the elimination sequence to apply More...
 
EliminationSequenceStrategy_elimination_sequence_strategy {nullptr}
 the elimination sequence strategy used by the triangulation More...
 
JunctionTreeStrategy_junction_tree_strategy {nullptr}
 the junction tree strategy used by the triangulation More...
 
const NodeProperty< Size > * _domain_sizes {nullptr}
 the domain sizes of the variables/nodes of the graph More...
 

Protected Member Functions

virtual void _initTriangulation (UndiGraph &graph) final
 the function called to initialize the triangulation process More...
 

Detailed Description

class for graph triangulations for which we enforce a given complete ordering on the nodes eliminations.

Definition at line 48 of file orderedTriangulation.h.

Constructor & Destructor Documentation

◆ OrderedTriangulation() [1/4]

gum::OrderedTriangulation::OrderedTriangulation ( const OrderedEliminationSequenceStrategy elimSeq = OrderedEliminationSequenceStrategy(),
const JunctionTreeStrategy JTStrategy = DefaultJunctionTreeStrategy(),
bool  minimality = false 
)

default constructor

Parameters
elimSeqthe elimination sequence used to triangulate the graph
JTStrategythe junction tree strategy used to create junction trees
minimalitya Boolean indicating whether we should enforce that the triangulation is minimal w.r.t. inclusion

Definition at line 37 of file orderedTriangulation.cpp.

Referenced by copyFactory(), and newFactory().

40  :
41  StaticTriangulation(elimSeq, JTStrategy, minimality) {
42  // for debugging purposes
43  GUM_CONSTRUCTOR(OrderedTriangulation);
44  }
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph
+ Here is the caller graph for this function:

◆ OrderedTriangulation() [2/4]

gum::OrderedTriangulation::OrderedTriangulation ( const UndiGraph graph,
const NodeProperty< Size > *  domsizes,
const std::vector< NodeId > *  sequence,
const OrderedEliminationSequenceStrategy elimSeq = OrderedEliminationSequenceStrategy(),
const JunctionTreeStrategy JTStrategy = DefaultJunctionTreeStrategy(),
bool  minimality = false 
)

constructor with a given graph

Parameters
graphthe graph to be triangulated, i.e., the nodes of which will be eliminated
domsizesthe domain sizes of the nodes to be eliminated
sequencethe order in which the nodes should be eliminated
elimSeqthe elimination sequence used to triangulate the graph. Only a reference/pointer to the sequence passed in argument is kept in the current class.
JTStrategythe junction tree strategy used to create junction trees
minimalitya Boolean indicating whether we should enforce that the triangulation is minimal w.r.t. inclusion
Warning
Note that we allow dom_sizes to be defined over nodes/variables that do not belong to graph. These sizes will simply be ignored. However, it is compulsory that all the nodes of graph belong to dom_sizes
note that, by aGrUM's rule, the graph, the domain sizes and the elimination sequence are not copied but only referenced by the triangulation algorithm.

Definition at line 47 of file orderedTriangulation.cpp.

References __order, gum::StaticTriangulation::_elimination_sequence_strategy, and setOrder().

53  :
54  StaticTriangulation(theGraph, dom, elimSeq, JTStrategy, minimality),
55  __order(order) {
56  static_cast< OrderedEliminationSequenceStrategy* >(
58  ->setOrder(__order);
59 
60  // for debugging purposes
61  GUM_CONSTRUCTOR(OrderedTriangulation);
62  }
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
const std::vector< NodeId > * __order
the elimination sequence to apply
virtual void setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination (only the reference is stored)
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph
+ Here is the call graph for this function:

◆ OrderedTriangulation() [3/4]

gum::OrderedTriangulation::OrderedTriangulation ( const OrderedTriangulation from)

copy constructor

Definition at line 65 of file orderedTriangulation.cpp.

65  :
66  StaticTriangulation(from), __order(from.__order) {
67  // for debugging purposes
68  GUM_CONS_CPY(OrderedTriangulation);
69  }
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
const std::vector< NodeId > * __order
the elimination sequence to apply
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph

◆ OrderedTriangulation() [4/4]

gum::OrderedTriangulation::OrderedTriangulation ( OrderedTriangulation &&  from)

move constructor

Definition at line 72 of file orderedTriangulation.cpp.

72  :
73  StaticTriangulation(std::move(from)), __order(from.__order) {
74  // for debugging purposes
75  GUM_CONS_MOV(OrderedTriangulation);
76  }
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
const std::vector< NodeId > * __order
the elimination sequence to apply
StaticTriangulation(const EliminationSequenceStrategy &elimSeq, const JunctionTreeStrategy &JTStrategy, bool minimality=false)
default constructor: without any graph

◆ ~OrderedTriangulation()

gum::OrderedTriangulation::~OrderedTriangulation ( )
virtual

destructor

Definition at line 92 of file orderedTriangulation.cpp.

92  {
93  // for debugging purposes
94  GUM_DESTRUCTOR(OrderedTriangulation);
95  }
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor

Member Function Documentation

◆ _initTriangulation()

void gum::OrderedTriangulation::_initTriangulation ( UndiGraph graph)
finalprotectedvirtual

the function called to initialize the triangulation process

This function is called when the triangulation process starts and is used to initialize the elimination sequence strategy. Actually, the graph that is modified by the triangulation algorithm is a copy of the original graph, and this copy need be known by the elimination sequence strategy. _initTriangulation is used to transmit this knowledge to the elimination sequence (through method setGraph of the elimination sequence class).

Parameters
graphthe very graph that is triangulated (this is a copy of _original_graph)

Reimplemented from gum::StaticTriangulation.

Definition at line 115 of file orderedTriangulation.cpp.

References __order, gum::Triangulation::_domain_sizes, gum::StaticTriangulation::_elimination_sequence_strategy, gum::OrderedEliminationSequenceStrategy::setGraph(), and gum::OrderedEliminationSequenceStrategy::setOrder().

115  {
116  OrderedEliminationSequenceStrategy* elim =
117  static_cast< OrderedEliminationSequenceStrategy* >(
119  elim->setGraph(&graph, _domain_sizes);
120  elim->setOrder(__order);
121  }
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const NodeProperty< Size > * _domain_sizes
the domain sizes of the variables/nodes of the graph
const std::vector< NodeId > * __order
the elimination sequence to apply
+ Here is the call graph for this function:

◆ clear()

void gum::StaticTriangulation::clear ( )
virtualinherited

reinitialize the graph to be triangulated to an empty graph

Implements gum::Triangulation.

Definition at line 165 of file staticTriangulation.cpp.

References gum::StaticTriangulation::__added_fill_ins, gum::StaticTriangulation::__elim_cliques, gum::StaticTriangulation::__elim_order, gum::StaticTriangulation::__elim_tree, gum::StaticTriangulation::__fill_ins, gum::StaticTriangulation::__has_elimination_tree, gum::StaticTriangulation::__has_fill_ins, gum::StaticTriangulation::__has_junction_tree, gum::StaticTriangulation::__has_max_prime_junction_tree, gum::StaticTriangulation::__has_triangulated_graph, gum::StaticTriangulation::__has_triangulation, gum::StaticTriangulation::__junction_tree, gum::StaticTriangulation::__max_prime_junction_tree, gum::StaticTriangulation::__node_2_max_prime_clique, gum::StaticTriangulation::__original_graph, gum::StaticTriangulation::__reverse_elim_order, gum::StaticTriangulation::__triangulated_graph, gum::StaticTriangulation::_elimination_sequence_strategy, gum::StaticTriangulation::_junction_tree_strategy, gum::JunctionTreeStrategy::clear(), gum::CliqueGraph::clear(), gum::EliminationSequenceStrategy::clear(), gum::UndiGraph::clear(), and gum::Set< Key, Alloc >::clear().

Referenced by gum::StaticTriangulation::setGraph().

165  {
166  // clear the factories
169 
170  // remove the current graphs
171  __original_graph = nullptr;
172  __junction_tree = nullptr;
174  __elim_tree.clear();
176  __elim_cliques.clear();
178 
179  // remove all fill-ins and orderings
180  __fill_ins.clear();
181  __added_fill_ins.clear();
182  __elim_order.clear();
183  __reverse_elim_order.clear();
184 
185  // indicates that the junction tree, the max prime tree, etc, are updated
186  __has_triangulation = true;
188  __has_elimination_tree = true;
189  __has_junction_tree = true;
191  __has_fill_ins = true;
192  }
virtual void clear()
clears the sequence (to prepare, for instance, a new elimination sequence)
virtual void clear()
removes all the nodes and edges from the graph
Definition: undiGraph_inl.h:43
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 (...
bool __has_max_prime_junction_tree
indicates whether a maximal prime subgraph junction tree has been constructed
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const UndiGraph * __original_graph
a pointer to the (external) original graph (which will be triangulated)
bool __has_triangulated_graph
a boolean indicating whether we have constructed the triangulated graph
virtual void clear()
removes all the cliques and separators from the graph (as well as their adjacent edges) ...
JunctionTreeStrategy * _junction_tree_strategy
the junction tree strategy used by the triangulation
UndiGraph __triangulated_graph
the triangulated graph
NodeProperty< NodeId > __reverse_elim_order
the elimination order (access by NodeId)
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_triangulation
a boolean indicating whether we have parformed a triangulation
virtual void clear()=0
resets the current junction tree strategy data structures
bool __has_junction_tree
a boolean indicating whether the junction tree has been constructed
CliqueGraph __max_prime_junction_tree
the maximal prime subgraph junction tree computed from the junction tree
NodeProperty< NodeSet > __elim_cliques
the cliques formed by the elimination of the nodes
bool __has_fill_ins
indicates whether we actually computed fill-ins
const CliqueGraph * __junction_tree
the junction tree computed by the algorithm
bool __has_elimination_tree
a boolean indicating whether the elimination tree has been computed
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
EdgeSet __fill_ins
the fill-ins added during the whole triangulation process
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyFactory()

OrderedTriangulation * gum::OrderedTriangulation::copyFactory ( ) const
finalvirtual

virtual copy constructor

Implements gum::StaticTriangulation.

Definition at line 87 of file orderedTriangulation.cpp.

References OrderedTriangulation().

87  {
88  return new OrderedTriangulation(*this);
89  }
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
+ Here is the call graph for this function:

◆ createdJunctionTreeClique()

NodeId gum::StaticTriangulation::createdJunctionTreeClique ( const NodeId  id)
virtualinherited

returns the Id of the clique of the junction tree created by the elimination of a given node during the triangulation process

Implements gum::Triangulation.

◆ createdJunctionTreeCliques()

const NodeProperty< NodeId >& gum::StaticTriangulation::createdJunctionTreeCliques ( )
virtualinherited

returns the Ids of the cliques of the junction tree created by the elimination of the nodes

Implements gum::Triangulation.

◆ createdMaxPrimeSubgraph()

NodeId gum::StaticTriangulation::createdMaxPrimeSubgraph ( const NodeId  id)
virtualinherited

returns the Id of the maximal prime subgraph created by the elimination of a given node during the triangulation process

Implements gum::Triangulation.

◆ domainSizes()

const NodeProperty< Size >* gum::Triangulation::domainSizes ( ) const
inherited

returns the domain sizes of the variables of the graph to be triangulated

◆ eliminationOrder() [1/2]

◆ eliminationOrder() [2/2]

Idx gum::StaticTriangulation::eliminationOrder ( const NodeId  )
virtualinherited

returns the index of a given node in the elimination order (0 = first node eliminated)

Implements gum::Triangulation.

◆ eliminationSequenceStrategy()

EliminationSequenceStrategy& gum::StaticTriangulation::eliminationSequenceStrategy ( ) const
inherited

returns the elimination sequence strategy used by the triangulation

◆ eliminationTree()

const CliqueGraph& gum::StaticTriangulation::eliminationTree ( )
virtualinherited

returns the elimination tree of a compatible ordering

Implements gum::Triangulation.

Referenced by gum::DefaultJunctionTreeStrategy::__computeJunctionTree().

+ Here is the caller graph for this function:

◆ fillIns()

const EdgeSet & gum::StaticTriangulation::fillIns ( )
virtualinherited

returns the fill-ins added by the triangulation algorithm

Implements gum::Triangulation.

Definition at line 679 of file staticTriangulation.cpp.

References gum::StaticTriangulation::__fill_ins, gum::StaticTriangulation::__has_fill_ins, gum::StaticTriangulation::__has_junction_tree, gum::StaticTriangulation::__has_triangulation, gum::StaticTriangulation::__junction_tree, gum::StaticTriangulation::__original_graph, gum::StaticTriangulation::__triangulate(), gum::StaticTriangulation::__we_want_fill_ins, gum::StaticTriangulation::_elimination_sequence_strategy, gum::CliqueGraph::clique(), gum::EdgeGraphPart::existsEdge(), gum::EliminationSequenceStrategy::fillIns(), gum::Set< Key, Alloc >::insert(), gum::StaticTriangulation::junctionTree(), gum::NodeGraphPart::nodes(), gum::EliminationSequenceStrategy::providesFillIns(), and gum::Set< Key, Alloc >::size().

679  {
680  // if we did not compute the triangulation yet, do it and commpute
681  // the fill-ins at the same time
682  if (!__has_triangulation) {
683  bool want_fill_ins = __we_want_fill_ins;
684  __we_want_fill_ins = true;
685  __triangulate();
686  __we_want_fill_ins = want_fill_ins;
687  __has_fill_ins = true;
688  }
689 
690  // here, we already computed a triangulation and we already computed
691  // the fill-ins, so return them
692  if (__has_fill_ins) {
695  else
696  return __fill_ins;
697  } else {
698  // ok, here, we shall compute the fill-ins as they were not precomputed
699  if (!__original_graph) return __fill_ins;
700 
701  // just in case, be sure that the junction tree has been constructed
703 
704  for (const auto clik_id : __junction_tree->nodes()) {
705  // for each clique, add the edges necessary to make it complete
706  const NodeSet& clique = __junction_tree->clique(clik_id);
707  std::vector< NodeId > clique_nodes(clique.size());
708  unsigned int i = 0;
709 
710  for (const auto node : clique) {
711  clique_nodes[i] = node;
712  i += 1;
713  }
714 
715  for (i = 0; i < clique_nodes.size(); ++i) {
716  for (unsigned int j = i + 1; j < clique_nodes.size(); ++j) {
717  Edge edge(clique_nodes[i], clique_nodes[j]);
718 
719  if (!__original_graph->existsEdge(edge)) {
720  try {
721  __fill_ins.insert(edge);
722  } catch (DuplicateElement&) {}
723  }
724  }
725  }
726  }
727 
728  return __fill_ins;
729  }
730  }
const CliqueGraph & junctionTree()
returns a compatible junction tree
virtual const EdgeSet & fillIns()
in case fill-ins are provided, this function returns the fill-ins due to all the nodes eliminated so ...
void __triangulate()
the function that performs the triangulation
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const UndiGraph * __original_graph
a pointer to the (external) original graph (which will be triangulated)
bool __has_triangulation
a boolean indicating whether we have parformed a triangulation
bool __has_junction_tree
a boolean indicating whether the junction tree has been constructed
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
const NodeSet & clique(const NodeId idClique) const
returns the set of nodes included into a given clique
bool __we_want_fill_ins
a boolean indicating if we want fill-ins list with the standard triangulation method ...
bool __has_fill_ins
indicates whether we actually computed fill-ins
const CliqueGraph * __junction_tree
the junction tree computed by the algorithm
EdgeSet __fill_ins
the fill-ins added during the whole triangulation process
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
virtual bool providesFillIns() const =0
indicates whether the fill-ins generated by the eliminated nodes, if needed, will be computed by the ...
+ Here is the call graph for this function:

◆ isMinimalityRequired()

virtual bool gum::StaticTriangulation::isMinimalityRequired ( ) const
finalvirtualinherited

indicates wether minimality is required

◆ junctionTree()

const CliqueGraph& gum::StaticTriangulation::junctionTree ( )
virtualinherited

returns a compatible junction tree

Implements gum::Triangulation.

Referenced by gum::StaticTriangulation::__computeMaxPrimeJunctionTree(), gum::StaticTriangulation::fillIns(), and gum::StaticTriangulation::triangulatedGraph().

+ Here is the caller graph for this function:

◆ junctionTreeStrategy()

JunctionTreeStrategy& gum::StaticTriangulation::junctionTreeStrategy ( ) const
inherited

returns the junction tree strategy used by the triangulation

◆ maxLog10CliqueDomainSize()

double gum::Triangulation::maxLog10CliqueDomainSize ( )
inherited

returns the max of log10DomainSize of the cliques in the junction tree.

This is usefull for instance to estimate the complexity (both in space and in time) of the inference that will use the junction tree.

This method is not 'const' since it can be called before building any junction tree and hence it needs to build it...

Definition at line 70 of file triangulation.cpp.

References gum::Triangulation::_domain_sizes, and gum::Triangulation::junctionTree().

Referenced by gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions().

70  {
71  double res = 0.0;
72  double dSize;
73  const JunctionTree& jt = junctionTree(); // here, the fact that we get
74  // a junction tree ensures that _domain_sizes is different from nullptr
75 
76  for (const NodeId cl : jt) {
77  dSize = 0.0;
78 
79  for (const auto node : jt.clique(cl))
80  dSize += std::log10((*_domain_sizes)[node]);
81 
82  if (res < dSize) res = dSize;
83  }
84 
85  return res;
86  }
const NodeProperty< Size > * _domain_sizes
the domain sizes of the variables/nodes of the graph
CliqueGraph JunctionTree
a junction tree is a clique graph satisfying the running intersection property and such that no cliqu...
Definition: cliqueGraph.h:302
virtual const CliqueGraph & junctionTree()=0
returns a compatible junction tree
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxPrimeSubgraphTree()

const CliqueGraph& gum::StaticTriangulation::maxPrimeSubgraphTree ( )
virtualinherited

returns a junction tree of maximal prime subgraphs

Warning
Actually, the cliques of the junction tree are guarranteed to be maximal prime subgraph of the original graph that was triangulated only if the triangulation performed is minimal (in the sense that removing any edge in the triangulated graph results in a nontriangulated graph). This can be ensured by requiring minimality of the triangulation.

Implements gum::Triangulation.

◆ newFactory()

OrderedTriangulation * gum::OrderedTriangulation::newFactory ( ) const
finalvirtual

returns a fresh triangulation over the same graph and of the same type as the current object (using the same sequence, etc.)

virtual copy constructor

note that we return a pointer as it enables subclasses to return pointers to their types, not Triangulation pointers. See item 25 of the more effective C++.

Implements gum::StaticTriangulation.

Definition at line 79 of file orderedTriangulation.cpp.

References gum::StaticTriangulation::_elimination_sequence_strategy, gum::StaticTriangulation::_junction_tree_strategy, and OrderedTriangulation().

79  {
80  return new OrderedTriangulation(
81  static_cast< const OrderedEliminationSequenceStrategy& >(
84  }
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
JunctionTreeStrategy * _junction_tree_strategy
the junction tree strategy used by the triangulation
OrderedTriangulation(const OrderedEliminationSequenceStrategy &elimSeq=OrderedEliminationSequenceStrategy(), const JunctionTreeStrategy &JTStrategy=DefaultJunctionTreeStrategy(), bool minimality=false)
default constructor
+ Here is the call graph for this function:

◆ operator=()

OrderedTriangulation& gum::OrderedTriangulation::operator= ( const OrderedTriangulation )
private

forbid copy operator

◆ originalGraph()

const UndiGraph* gum::StaticTriangulation::originalGraph ( ) const
inherited

returns the graph to be triangulated

Warning
if we have not set yet a graph, then originalGraph () will return a nullptr.

Referenced by gum::DefaultJunctionTreeStrategy::copyFactory().

+ Here is the caller graph for this function:

◆ reverseEliminationOrder()

const NodeProperty< NodeId >& gum::StaticTriangulation::reverseEliminationOrder ( )
inherited

returns a table indicating, for each node, at which step it was deleted by the triangulation process

◆ setFillIns()

void gum::StaticTriangulation::setFillIns ( bool  )
inherited

sets/unsets the record of the fill-ins in the standard triangulation procedure

◆ setGraph()

void gum::OrderedTriangulation::setGraph ( const UndiGraph graph,
const NodeProperty< Size > *  domsizes 
)
finalvirtual

initialize the triangulation data structures for a new graph

Parameters
graphthe graph to be triangulated, i.e., the nodes of which will be eliminated
domsizesthe domain sizes of the nodes to be eliminated
sequencethe order in which the nodes should be eliminated
Warning
note that, by aGrUM's rule, the graph and the domain sizes are not notcopied but only referenced by the triangulation algorithm.

Reimplemented from gum::StaticTriangulation.

Definition at line 98 of file orderedTriangulation.cpp.

References __order, gum::StaticTriangulation::_elimination_sequence_strategy, gum::StaticTriangulation::setGraph(), and setOrder().

99  {
100  StaticTriangulation::setGraph(graph, domsizes);
101  static_cast< OrderedEliminationSequenceStrategy* >(
103  ->setOrder(__order);
104  }
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const std::vector< NodeId > * __order
the elimination sequence to apply
virtual void setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination (only the reference is stored)
virtual void setGraph(const UndiGraph *graph, const NodeProperty< Size > *domsizes)
initialize the triangulation data structures for a new graph
+ Here is the call graph for this function:

◆ setMinimalRequirement()

void gum::StaticTriangulation::setMinimalRequirement ( bool  )
inherited

sets/unset the minimality requirement

◆ setOrder()

void gum::OrderedTriangulation::setOrder ( const std::vector< NodeId > *  order)
finalvirtual

sets the sequence of elimination (only the reference is stored)

sets the sequence of elimination

The elimination sequence is kept outside this class for efficiency reasons.

Definition at line 107 of file orderedTriangulation.cpp.

References __order, and gum::StaticTriangulation::_elimination_sequence_strategy.

Referenced by OrderedTriangulation(), and setGraph().

107  {
108  __order = order;
109  static_cast< OrderedEliminationSequenceStrategy* >(
111  ->setOrder(__order);
112  }
EliminationSequenceStrategy * _elimination_sequence_strategy
the elimination sequence strategy used by the triangulation
const std::vector< NodeId > * __order
the elimination sequence to apply
virtual void setOrder(const std::vector< NodeId > *order) final
sets the sequence of elimination (only the reference is stored)
+ Here is the caller graph for this function:

◆ triangulatedGraph()

const UndiGraph & gum::StaticTriangulation::triangulatedGraph ( )
virtualinherited

returns the triangulated graph

Implements gum::Triangulation.

Definition at line 487 of file staticTriangulation.cpp.

References gum::StaticTriangulation::__has_junction_tree, gum::StaticTriangulation::__has_triangulated_graph, gum::StaticTriangulation::__has_triangulation, gum::StaticTriangulation::__junction_tree, gum::StaticTriangulation::__original_graph, gum::StaticTriangulation::__triangulate(), gum::StaticTriangulation::__triangulated_graph, gum::UndiGraph::addEdge(), gum::StaticTriangulation::junctionTree(), and gum::Set< Key, Alloc >::size().

487  {
489 
490  // if we did not construct the triangulated graph during the triangulation,
491  // that is, we just constructed the junction tree, we shall construct it now
493  // just in case, be sure that the junction tree has been constructed
495 
496  // copy the original graph
498 
499  for (const auto clik_id : *__junction_tree) {
500  // for each clique, add the edges necessary to make it complete
501  const NodeSet& clique = __junction_tree->clique(clik_id);
502  std::vector< NodeId > clique_nodes(clique.size());
503  unsigned int i = 0;
504 
505  for (const auto node : clique) {
506  clique_nodes[i] = node;
507  i += 1;
508  }
509 
510  for (i = 0; i < clique_nodes.size(); ++i) {
511  for (unsigned int j = i + 1; j < clique_nodes.size(); ++j) {
512  try {
513  __triangulated_graph.addEdge(clique_nodes[i], clique_nodes[j]);
514  } catch (DuplicateElement&) {}
515  }
516  }
517  }
518 
520  }
521 
522  return __triangulated_graph;
523  }
const CliqueGraph & junctionTree()
returns a compatible junction tree
void __triangulate()
the function that performs the triangulation
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const UndiGraph * __original_graph
a pointer to the (external) original graph (which will be triangulated)
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
Definition: undiGraph_inl.h:35
bool __has_triangulated_graph
a boolean indicating whether we have constructed the triangulated graph
UndiGraph __triangulated_graph
the triangulated graph
bool __has_triangulation
a boolean indicating whether we have parformed a triangulation
bool __has_junction_tree
a boolean indicating whether the junction tree has been constructed
const CliqueGraph * __junction_tree
the junction tree computed by the algorithm
+ Here is the call graph for this function:

Member Data Documentation

◆ __order

const std::vector< NodeId >* gum::OrderedTriangulation::__order {nullptr}
protected

the elimination sequence to apply

Warning
__order is not owned by the orderedTriangulation class

Definition at line 155 of file orderedTriangulation.h.

Referenced by _initTriangulation(), OrderedTriangulation(), setGraph(), and setOrder().

◆ _domain_sizes

const NodeProperty< Size >* gum::Triangulation::_domain_sizes {nullptr}
protectedinherited

◆ _elimination_sequence_strategy

◆ _junction_tree_strategy

JunctionTreeStrategy* gum::StaticTriangulation::_junction_tree_strategy {nullptr}
protectedinherited

The documentation for this class was generated from the following files: