aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
internalNode.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
50#ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H
51#define GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H
52
53#include <agrum/agrum.h>
54
58
59namespace gum {
60
61 // clang-format off
69 // clang-format on
70
71 struct Parent {
74
78 Parent(NodeId pi, Idx m);
79
83 Parent(const Parent& src);
84
85 // ============================================================================
87 // ============================================================================
89
93 void* operator new(size_t s);
94
98 void operator delete(void* p);
99
101 // ============================================================================
103 // ============================================================================
105
106 bool operator==(const Parent& comp) const;
107
108
109 Parent& operator=(const Parent& src);
111 };
112
113 // clang-format off
121 // clang-format on
122
124 private:
127
144
147
149 void _setNodeVar_(const DiscreteVariable* v);
150
151 public:
152 // ============================================================================
154 // ============================================================================
156
161 InternalNode();
162
169 explicit InternalNode(const DiscreteVariable* v);
170
181 InternalNode(const DiscreteVariable* v, NodeId* sons);
182
188 // ============================================================================
190 // ============================================================================
192
196 void* operator new(size_t s);
197
201 void operator delete(void* p);
202
204 // ============================================================================
206 // ============================================================================
208
216 void setNode(const DiscreteVariable* v, NodeId* sons);
217
219 // ============================================================================
221 // ============================================================================
223
227 void setNodeVar(const DiscreteVariable* v);
228
232 const DiscreteVariable* nodeVar() const;
233
235 // ============================================================================
237 // ============================================================================
239
243 void setSon(Idx modality, NodeId son);
244
248 NodeId son(Idx modality) const;
249
253 Idx nbSons() const;
254
256 // ============================================================================
258 // ============================================================================
260
264 void addParent(NodeId parent, Idx modality);
265
269 void removeParent(NodeId parent, Idx modality);
270
275
279 const Link< Parent >* parents() const;
280
282 // ============================================================================
284 // ============================================================================
286
290 static NodeId* allocateNodeSons(const DiscreteVariable* v);
291
295 static void deallocateNodeSons(const DiscreteVariable* v, NodeId* s);
296
298 };
299
300} // End of namespace gum
301
302#ifndef GUM_NO_INLINE
304#endif /* GUM_NO_INLINE */
305
306#endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_INTERNAL_NODE_H */
Base class for discrete random variable.
InternalNode()
Default Constructor Creates an empty node with no variable attached.
void setNodeVar(const DiscreteVariable *v)
Set the node variable.
void setNode(const DiscreteVariable *v, NodeId *sons)
Allows you to respecify the node, changing its attached variable as well as its son map.
const DiscreteVariable * nodeVar() const
Returns the node variable.
void _setNodeVar_(const DiscreteVariable *v)
Set the node variable.
NodeId * _nodeSons_
Table of sons of the node.
const DiscreteVariable * _nodeVar_
Variable associated to such node.
void addParent(NodeId parent, Idx modality)
Adds a parent.
Idx nbSons() const
Returns the number of sons.
~InternalNode()
Class destructors.
static NodeId * allocateNodeSons(const DiscreteVariable *v)
Allocates a table of nodeid of the size given in parameter.
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId son(Idx modality) const
Returns the son at a given index.
void removeParent(NodeId parent, Idx modality)
Removes a parent.
Link< Parent > * parents()
Returns the list of parents.
void setSon(Idx modality, NodeId son)
Sets the node's son.
LinkedList< Parent > _nodeParents_
The list of the node's parent.
Chain list allocated using the SmallObjectAllocator.
Definition link.h:155
Base class for discrete random variable.
some utils for topology : NodeId, Edge, Arc and consorts ...
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
Inline implementation of the InternalNode class.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
bool operator==(const Parent &comp) const
Parent & operator=(const Parent &src)
Parent(NodeId pi, Idx m)
Class constructor.
Parent(const Parent &src)
Copy constructor.
NodeId parentId