aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
cliqueGraph_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief inline source of basic clique graphs
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
30 // to ease parser in IDE
31 # include <agrum/tools/graphs/cliqueGraph.h>
32 
33 namespace gum {
34 
35  /// copy operator
36  INLINE CliqueGraph& CliqueGraph::operator=(const CliqueGraph& g) {
37  if (this != &g) {
38  UndiGraph::operator=(g);
41  }
42 
43  return *this;
44  }
45 
46  INLINE void CliqueGraph::addEdge(const NodeId first, const NodeId second) {
48 
49  if (!existsEdge(edge)) {
50  // create the edge in the graph
52 
53  // create the separator
55  }
56  }
57 
58  /// removes an edge (and its separator) from the clique graph
59 
60  INLINE void CliqueGraph::eraseEdge(const Edge& edge) {
61  if (existsEdge(edge)) {
64  }
65  }
66 
67  /// adds a new clique to the graph
68 
70  // create the new node in the graph
72 
73  // update the set of nodes of the clique
75  return new_node;
76  }
77 
79 
80  /// adds a new clique to the graph
81 
82  INLINE void CliqueGraph::addNode(const NodeId id, const NodeSet& clique) {
83  // create the new node in the graph
85 
86  // update the set of nodes of the clique
88  }
89 
90  INLINE void CliqueGraph::addNode(const NodeId id) { addNode(id, NodeSet()); }
91 
92  /// removes a given clique from the clique graph
93 
94  INLINE void CliqueGraph::eraseNode(const NodeId id) {
95  // check if the node belongs to the graph
96  if (!exists(id)) return;
97 
98  // remove the separators
99  auto nei = neighbours(id);
100  for (auto iter = nei.beginSafe(); iter != nei.endSafe();
101  ++iter) // safe iterator needed here
102  eraseEdge(Edge(*iter, id));
103 
104  // erase the clique set
105  cliques__.erase(id);
106 
107  // erase the node and its neighbours from the graph
109  }
110 
111  /// returns the set of nodes included into a given clique
112 
113  INLINE const NodeSet& CliqueGraph::clique(const NodeId clique) const {
114  return cliques__[clique];
115  }
116 
117  /// returns the id of a clique containing the node the id of which is in
118  /// argument
119 
120  INLINE NodeId CliqueGraph::container(const NodeId id) const {
121  for (const auto& elt: cliques__)
122  if (elt.second.contains(id)) return elt.first;
123 
124  GUM_ERROR(NotFound, "This node belongs to no clique");
125  }
126 
127  /// function used to update the separators__ when clique__/edges are modified
128 
130  for (const auto nei: neighbours(id1))
132  }
133 
134  /// changes the set of nodes included into a given clique and returns the new
135  /// set
136 
137  INLINE void CliqueGraph::setClique(const NodeId id, const NodeSet& new_clique) {
138  // get the current clique set
141  }
142 
143  /// returns the separator included in a given edge
144 
145  INLINE const NodeSet& CliqueGraph::separator(const Edge& edge) const {
146  return separators__[edge];
147  }
148 
149  /// returns the separator included in an edge specified by its extremities
150 
152  const NodeId node2) const {
153  return separator(Edge(node1, node2));
154  }
155 
156  /// indicates whether the graph is a join tree
157 
158  INLINE bool CliqueGraph::isJoinTree() const {
160  }
161 
162  /// removes all the nodes from the graph (as well as their adjacent
163  /// edges/arcs)
164 
165  INLINE void CliqueGraph::clear() {
166  UndiGraph::clear();
167  cliques__.clear();
169  }
170 
171  /// removes all the edges from the clique graph
172 
173  INLINE void CliqueGraph::clearEdges() {
176  }
177 
178  /// checks whether two clique graphs are different
179 
180  INLINE bool CliqueGraph::operator!=(const CliqueGraph& from) const {
181  return (!operator==(from));
182  }
183 
184 } /* namespace gum */
185 
186 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669