aGrUM  0.16.0
cliqueGraph.h
Go to the documentation of this file.
1 
28 #ifndef GUM_CLIQUE_GRAPH_H
29 #define GUM_CLIQUE_GRAPH_H
30 
31 #include <iostream>
32 
33 #include <agrum/agrum.h>
34 
35 #include <agrum/graphs/undiGraph.h>
36 
37 namespace gum {
38  /* ===========================================================================
39  */
40  /* === GRAPHS OF CLIQUES ===
41  */
42  /* ===========================================================================
43  */
55  /* ===========================================================================
56  */
57 
58  class CliqueGraph : public UndiGraph {
59  public:
60  // ############################################################################
62  // ############################################################################
64 
66 
71  explicit CliqueGraph(Size nodes_size = HashTableConst::default_size,
72  bool nodes_resize_policy = true,
74  bool edges_resize_policy = true);
75 
77 
79  CliqueGraph(const CliqueGraph& from);
80 
82 
83  virtual ~CliqueGraph();
84 
86 
87  // ############################################################################
89  // ############################################################################
91 
93 
101  virtual void addEdge(const NodeId first, const NodeId second);
102 
104 
108  virtual void eraseEdge(const Edge& edge);
109 
111 
112  virtual void clearEdges();
113 
115 
116  NodeId addNode(const NodeSet& clique);
117 
119 
120  virtual NodeId addNode();
121 
123 
125  virtual void addNode(const NodeId id, const NodeSet& clique);
126 
128 
130  virtual void addNode(const NodeId id);
131 
133 
136  virtual void eraseNode(const NodeId node);
137 
141  virtual void clear();
142 
144 
147  const NodeSet& clique(const NodeId idClique) const;
148 
158  NodeId container(const NodeId idNode) const;
159 
165  virtual void setClique(const NodeId idClique, const NodeSet& new_clique);
166 
174  virtual void addToClique(const NodeId clique_id, const NodeId node_id);
175 
177 
181  virtual void eraseFromClique(const NodeId clique_id, const NodeId node_id);
182 
184 
187  const NodeSet& separator(const Edge& edge) const;
188 
190 
193  const NodeSet& separator(const NodeId clique1, const NodeId clique) const;
194 
197 
199  std::vector< NodeId > containerPath(const NodeId node1,
200  const NodeId node2) const;
201 
203 
205  bool hasRunningIntersection() const;
206 
208 
209  bool isJoinTree() const;
210 
212 
213  virtual const std::string toString() const;
214 
216 
217  virtual const std::string toDot() const;
218 
220 
221  // ############################################################################
223  // ############################################################################
225 
227 
228  CliqueGraph& operator=(const CliqueGraph& from);
229 
231 
232  bool operator!=(const CliqueGraph& from) const;
233 
235 
236  bool operator==(const CliqueGraph& from) const;
237 
239 
240  private:
243 
246 
248 
249  void __updateSeparators(const NodeId clique1);
250 
252 
257 
260 
264 
267 
270 
290  };
291 
293 
294  bool __runningIntersectionDFS(const NodeId clique,
295  const NodeId from,
296  __RunningIntersect& infos_DFS) const;
297  };
298 
303 
307 
309 
310  std::ostream& operator<<(std::ostream&, const CliqueGraph&);
311 
312 } /* namespace gum */
313 
314 #ifndef GUM_NO_INLINE
316 #endif // GUM_NOINLINE
317 
318 #endif /* GUM_CLIQUE_GRAPH_H */
bool operator==(const CliqueGraph &from) const
checks whether two clique graphs are equal
bool operator!=(const CliqueGraph &from) const
checks whether two clique graphs are different
bool isJoinTree() const
indicates whether the graph is a join tree
virtual void eraseNode(const NodeId node)
removes a given clique from the clique graph
const NodeSet & separator(const Edge &edge) const
returns the separator included in a given edge
virtual void setClique(const NodeId idClique, const NodeSet &new_clique)
changes the set of nodes included into a given clique and returns the new set
virtual const std::string toDot() const
friendly displays the content of the CliqueGraph in DOT format
static constexpr Size default_size
The default number of slots in hashtables.
Definition: hashTable.h:80
virtual void clear()
removes all the cliques and separators from the graph (as well as their adjacent edges) ...
structure used for the computation of the running intersection property
Definition: cliqueGraph.h:253
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
NodeProperty< NodeSet > cliques_DFS_chain
for each clique, the list of its nodes that require accessing the clique through a chain ...
Definition: cliqueGraph.h:289
NodeSet nodes_DFS_seen
set of the nodes examined during the current DFS
Definition: cliqueGraph.h:269
The class for generic Hash Tables.
Definition: hashTable.h:679
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
bool __runningIntersectionDFS(const NodeId clique, const NodeId from, __RunningIntersect &infos_DFS) const
function used for the computation of the running intersection property
NodeProperty< NodeSet > __cliques
the set of nodes contained into the cliques
Definition: cliqueGraph.h:242
virtual ~CliqueGraph()
destructor
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:605
void __updateSeparators(const NodeId clique1)
function used to update the separators when a clique is modified
virtual void addToClique(const NodeId clique_id, const NodeId node_id)
changes the set of nodes included into a given clique and returns the new set
NodeSet visited_cliques
structure indicating for each clique whether it has been examined by a DFS (Depth First Search) ...
Definition: cliqueGraph.h:256
CliqueGraph JoinTree
a join tree is a clique graph satisfying the running intersection property (but some cliques may be i...
Definition: cliqueGraph.h:306
virtual void eraseEdge(const Edge &edge)
removes an edge (and its separator) from the clique graph
virtual const std::string toString() const
friendly displays the content of the CliqueGraph
virtual void addEdge(const NodeId first, const NodeId second)
inserts a new edge between two cliques
const NodeSet & clique(const NodeId idClique) const
returns the set of nodes included into a given clique
NodeSet nodes_other_components
structure indicating the nodes that belong to other connected components
Definition: cliqueGraph.h:263
Basic graph of cliques.
Definition: cliqueGraph.h:58
NodeId container(const NodeId idNode) const
returns the id of a clique containing the node the id of which is in argument
CliqueGraph JunctionTree
a junction tree is a clique graph satisfying the running intersection property and such that no cliqu...
Definition: cliqueGraph.h:302
The base class for all undirected edges.
std::vector< NodeId > containerPath(const NodeId node1, const NodeId node2) const
returns a path from a clique containing node1 to a clique containing node2
NodeSet nodes_DFS_forbidden
the nodes that are currently forbidden by separators in the DFS
Definition: cliqueGraph.h:266
Base class for undirected graphs.
Definition: undiGraph.h:109
EdgeProperty< NodeSet > __separators
the set of nodes contained into the separators
Definition: cliqueGraph.h:245
CliqueGraph & operator=(const CliqueGraph &from)
copy operator
virtual NodeId addNode()
adds a new clique to the graph
CliqueGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
basic constructor: creates an empty clique graph
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
virtual void eraseFromClique(const NodeId clique_id, const NodeId node_id)
remove a node from a clique
virtual void clearEdges()
removes all edges and their separators
Size NodeId
Type for node ids.
Definition: graphElements.h:98
bool hasRunningIntersection() const
indicates whether the running intersection property holds
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.