aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
gum::InternalNode Class Reference

Structure used to represent a node internal structure. More...

#include <agrum/tools/multidim/FunctionGraphUtilities/internalNode.h>

+ Collaboration diagram for gum::InternalNode:

Public Member Functions

Constructors and Destructors
 InternalNode ()
 Default Constructor Creates an empty node with no variable attached. More...
 
 InternalNode (const DiscreteVariable *v)
 Class constructor. More...
 
 InternalNode (const DiscreteVariable *v, NodeId *sons)
 Constructor. More...
 
 ~InternalNode ()
 Class destructors. More...
 
Allocators and Deallocators redefinition
void * operator new (size_t s)
 New operator. More...
 
void operator delete (void *p)
 Delete operator. More...
 
Node handlers
void setNode (const DiscreteVariable *v, NodeId *sons)
 Allows you to respecify the node, changing its attached variable as well as its son map. More...
 
Var handlers
void setNodeVar (const DiscreteVariable *v)
 Set the node variable. More...
 
const DiscreteVariablenodeVar () const
 Returns the node variable. More...
 
Sons handlers
void setSon (Idx modality, NodeId son)
 Sets the node's son. More...
 
NodeId son (Idx modality) const
 Returns the son at a given index. More...
 
Idx nbSons () const
 Returns the number of sons. More...
 
Parent handlers
void addParent (NodeId parent, Idx modality)
 Adds a parent. More...
 
void removeParent (NodeId parent, Idx modality)
 Removes a parent. More...
 
Link< Parent > * parents ()
 Returns the list of parents. More...
 
const Link< Parent > * parents () const
 Returns the list of parents. More...
 

Static Public Member Functions

Allocator/deallocator
static NodeIdallocateNodeSons (const DiscreteVariable *v)
 Allocates a table of nodeid of the size given in parameter. More...
 
static void deallocateNodeSons (const DiscreteVariable *v, NodeId *s)
 Deallocates a NodeSons table. More...
 

Detailed Description

Structure used to represent a node internal structure.

Definition at line 102 of file internalNode.h.

Constructor & Destructor Documentation

◆ InternalNode() [1/3]

gum::InternalNode::InternalNode ( )

Default Constructor Creates an empty node with no variable attached.

Definition at line 41 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

41  {
42  GUM_CONSTRUCTOR(InternalNode);
43  nodeVar__ = nullptr;
44  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ InternalNode() [2/3]

gum::InternalNode::InternalNode ( const DiscreteVariable v)
explicit

Class constructor.

Creates a node and attached the specified variable. Initializes the sons.

Definition at line 46 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

46  {
47  GUM_CONSTRUCTOR(InternalNode);
48  setNodeVar__(v);
49  }
void setNodeVar__(const DiscreteVariable *v)
Set the node variable.
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ InternalNode() [3/3]

gum::InternalNode::InternalNode ( const DiscreteVariable v,
NodeId sons 
)

Constructor.

Creates a node and attached the specified variable. Also attached the given on map (and will handle it by itself especially deallocate it)

Warning
You'd better known what you're doing if you're using this one. sons must have the size of domainSize of v or the program will fail!

Definition at line 51 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

51  {
52  GUM_CONSTRUCTOR(InternalNode);
53  nodeVar__ = v;
54  nodeSons__ = sons;
55  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ ~InternalNode()

gum::InternalNode::~InternalNode ( )

Class destructors.

Definition at line 60 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

60  {
61  GUM_DESTRUCTOR(InternalNode);
63  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

Member Function Documentation

◆ addParent()

void gum::InternalNode::addParent ( NodeId  parent,
Idx  modality 
)

Adds a parent.

Definition at line 108 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

108  {
109  nodeParents__.addLink(Parent(parent, modality));
110  }
LinkedList< Parent > nodeParents__
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ allocateNodeSons()

NodeId * gum::InternalNode::allocateNodeSons ( const DiscreteVariable v)
static

Allocates a table of nodeid of the size given in parameter.

Definition at line 68 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

68  {
69  NodeId* sons
70  = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * v->domainSize()));
71  for (gum::Idx i = 0; i < v->domainSize(); ++i)
72  sons[i] = 0;
73  return sons;
74  }
#define ALLOCATE(x)
Size Idx
Type for indexes.
Definition: types.h:52
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ deallocateNodeSons()

void gum::InternalNode::deallocateNodeSons ( const DiscreteVariable v,
NodeId s 
)
static

Deallocates a NodeSons table.

Definition at line 79 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

79  {
80  DEALLOCATE(s, sizeof(NodeId) * v->domainSize());
81  }
#define DEALLOCATE(x, y)
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ nbSons()

INLINE Idx gum::InternalNode::nbSons ( ) const

Returns the number of sons.

Definition at line 92 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

92 { return nodeVar__->domainSize(); }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
virtual Size domainSize() const =0
+ Here is the call graph for this function:

◆ nodeVar()

INLINE const DiscreteVariable * gum::InternalNode::nodeVar ( ) const

Returns the node variable.

Definition at line 81 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

81 { return nodeVar__; }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
+ Here is the call graph for this function:

◆ operator delete()

INLINE void gum::InternalNode::operator delete ( void *  p)

Delete operator.

Definition at line 76 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

76  {
78  }
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ operator new()

INLINE void * gum::InternalNode::operator new ( size_t  s)

New operator.

Definition at line 71 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

71  {
73  }
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
+ Here is the call graph for this function:

◆ parents() [1/2]

INLINE Link< Parent > * gum::InternalNode::parents ( )

Returns the list of parents.

Definition at line 95 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

95 { return nodeParents__.list(); }
LinkedList< Parent > nodeParents__
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ parents() [2/2]

INLINE const Link< Parent > * gum::InternalNode::parents ( ) const

Returns the list of parents.

Definition at line 98 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

98  {
99  return nodeParents__.list();
100  }
LinkedList< Parent > nodeParents__
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ removeParent()

void gum::InternalNode::removeParent ( NodeId  parent,
Idx  modality 
)

Removes a parent.

Definition at line 112 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

112  {
113  nodeParents__.searchAndRemoveLink(Parent(parent, modality));
114  }
LinkedList< Parent > nodeParents__
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ setNode()

void gum::InternalNode::setNode ( const DiscreteVariable v,
NodeId sons 
)

Allows you to respecify the node, changing its attached variable as well as its son map.

Warning
You'd better known what you're doing if you're using this one. sons must have the size of domainSize of v or the program will fail!

Definition at line 86 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

86  {
88  nodeVar__ = v;
89  nodeSons__ = sons;
90  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
+ Here is the call graph for this function:

◆ setNodeVar()

void gum::InternalNode::setNodeVar ( const DiscreteVariable v)

Set the node variable.

Definition at line 95 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

95  {
97  setNodeVar__(v);
98  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
void setNodeVar__(const DiscreteVariable *v)
Set the node variable.
+ Here is the call graph for this function:

◆ setNodeVar__()

void gum::InternalNode::setNodeVar__ ( const DiscreteVariable v)
private

Set the node variable.

Definition at line 100 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

100  {
101  nodeVar__ = v;
103  }
const DiscreteVariable * nodeVar__
Variable associated to such node.
Definition: internalNode.h:105
static NodeId * allocateNodeSons(const DiscreteVariable *v)
Allocates a table of nodeid of the size given in parameter.
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

◆ setSon()

INLINE void gum::InternalNode::setSon ( Idx  modality,
NodeId  son 
)

Sets the node's son.

Definition at line 84 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

84  {
85  nodeSons__[modality] = son;
86  }
NodeId son(Idx modality) const
Returns the son at a given index.
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

◆ son()

INLINE NodeId gum::InternalNode::son ( Idx  modality) const

Returns the son at a given index.

Definition at line 89 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

89 { return nodeSons__[modality]; }
NodeId * nodeSons__
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

Member Data Documentation

◆ nodeParents__

LinkedList< Parent > gum::InternalNode::nodeParents__
private

The list of the node's parent.

Definition at line 125 of file internalNode.h.

◆ nodeSons__

NodeId* gum::InternalNode::nodeSons__
private

Table of sons of the node.

Each son is bound to a modality of the variable. So those modalities are used has indexes for that table.

_____________________________
| | | | |
| son1 | son2 | son3 | son4 |
|______|______|______|______|
x1 x2 x3 x4

Definition at line 122 of file internalNode.h.

◆ nodeVar__

const DiscreteVariable* gum::InternalNode::nodeVar__
private

Variable associated to such node.

Definition at line 105 of file internalNode.h.


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