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

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

#include <agrum/base/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.
 InternalNode (const DiscreteVariable *v)
 Class constructor.
 InternalNode (const DiscreteVariable *v, NodeId *sons)
 Constructor.
 ~InternalNode ()
 Class destructors.
Allocators and Deallocators redefinition
void * operator new (size_t s)
 New operator.
void operator delete (void *p)
 Delete operator.
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.
Var handlers
void setNodeVar (const DiscreteVariable *v)
 Set the node variable.
const DiscreteVariablenodeVar () const
 Returns the node variable.
Sons handlers
void setSon (Idx modality, NodeId son)
 Sets the node's son.
NodeId son (Idx modality) const
 Returns the son at a given index.
Idx nbSons () const
 Returns the number of sons.
Parent handlers
void addParent (NodeId parent, Idx modality)
 Adds a parent.
void removeParent (NodeId parent, Idx modality)
 Removes a parent.
Link< Parent > * parents ()
 Returns the list of parents.
const Link< Parent > * parents () const
 Returns the list of parents.

Static Public Member Functions

Allocator/deallocator
static NodeIdallocateNodeSons (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.

Private Member Functions

void _setNodeVar_ (const DiscreteVariable *v)
 Set the node variable.

Private Attributes

const DiscreteVariable_nodeVar_
 Variable associated to such node.
NodeId_nodeSons_
 Table of sons of the node.
LinkedList< Parent_nodeParents_
 The list of the node's parent.

Detailed Description

Structure used to represent a node internal structure.

Definition at line 124 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 61 of file internalNode.cpp.

61 {
62 GUM_CONSTRUCTOR(InternalNode);
63 _nodeVar_ = nullptr;
64 }
InternalNode()
Default Constructor Creates an empty node with no variable attached.
const DiscreteVariable * _nodeVar_
Variable associated to such node.

References InternalNode(), and _nodeVar_.

Referenced by InternalNode(), InternalNode(), InternalNode(), ~InternalNode(), and operator delete().

Here is the call graph for this function:
Here is the caller 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 66 of file internalNode.cpp.

66 {
67 GUM_CONSTRUCTOR(InternalNode);
68 _setNodeVar_(v);
69 }
void _setNodeVar_(const DiscreteVariable *v)
Set the node variable.

References InternalNode(), and _setNodeVar_().

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 71 of file internalNode.cpp.

71 {
72 GUM_CONSTRUCTOR(InternalNode);
73 _nodeVar_ = v;
74 _nodeSons_ = sons;
75 }
NodeId * _nodeSons_
Table of sons of the node.

References InternalNode(), _nodeSons_, and _nodeVar_.

Here is the call graph for this function:

◆ ~InternalNode()

gum::InternalNode::~InternalNode ( )

Class destructors.

Definition at line 80 of file internalNode.cpp.

80 {
81 GUM_DESTRUCTOR(InternalNode);
83 }
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.

References InternalNode(), _nodeSons_, _nodeVar_, and deallocateNodeSons().

Here is the call graph for this function:

Member Function Documentation

◆ _setNodeVar_()

void gum::InternalNode::_setNodeVar_ ( const DiscreteVariable * v)
private

Set the node variable.

Definition at line 119 of file internalNode.cpp.

119 {
120 _nodeVar_ = v;
122 }
static NodeId * allocateNodeSons(const DiscreteVariable *v)
Allocates a table of nodeid of the size given in parameter.

References _nodeSons_, _nodeVar_, and allocateNodeSons().

Referenced by InternalNode(), and setNodeVar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addParent()

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

Adds a parent.

Definition at line 127 of file internalNode.cpp.

127 {
128 _nodeParents_.addLink(Parent(parent, modality));
129 }
LinkedList< Parent > _nodeParents_
The list of the node's parent.

References _nodeParents_.

◆ allocateNodeSons()

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

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

Definition at line 88 of file internalNode.cpp.

88 {
89 NodeId* sons = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * v->domainSize()));
90 for (gum::Idx i = 0; i < v->domainSize(); ++i)
91 sons[i] = 0;
92 return sons;
93 }
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
#define ALLOCATE(x)

References ALLOCATE, and gum::DiscreteVariable::domainSize().

Referenced by _setNodeVar_(), and gum::MultiDimFunctionGraphManager< double, ExactTerminalNodePolicy >::clean().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deallocateNodeSons()

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

Deallocates a NodeSons table.

Definition at line 98 of file internalNode.cpp.

98 {
99 DEALLOCATE(s, sizeof(NodeId) * v->domainSize());
100 }
#define DEALLOCATE(x, y)

References DEALLOCATE, and gum::DiscreteVariable::domainSize().

Referenced by ~InternalNode(), setNode(), and setNodeVar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nbSons()

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

Returns the number of sons.

Definition at line 106 of file internalNode_inl.h.

106{ return _nodeVar_->domainSize(); }

References _nodeVar_.

Referenced by gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addInternalNode_(), gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::migrateNode_(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot().

Here is the caller graph for this function:

◆ nodeVar()

◆ operator delete()

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

Delete operator.

Definition at line 92 of file internalNode_inl.h.

92 {
94 }
static SmallObjectAllocator & instance()
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.

References InternalNode(), gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ operator new()

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

New operator.

Definition at line 87 of file internalNode_inl.h.

87 {
89 }
void * allocate(const size_t &objectSize)
Allocates a block.

References gum::SmallObjectAllocator::allocate(), and gum::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 109 of file internalNode_inl.h.

109{ return _nodeParents_.list(); }

References _nodeParents_.

Referenced by gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::migrateNode_(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot().

Here is the caller graph for this function:

◆ parents() [2/2]

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

Returns the list of parents.

Definition at line 112 of file internalNode_inl.h.

112{ return _nodeParents_.list(); }

References _nodeParents_.

◆ removeParent()

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

Removes a parent.

Definition at line 131 of file internalNode.cpp.

131 {
132 _nodeParents_.searchAndRemoveLink(Parent(parent, modality));
133 }

References _nodeParents_.

◆ 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 105 of file internalNode.cpp.

105 {
107 _nodeVar_ = v;
108 _nodeSons_ = sons;
109 }

References _nodeSons_, _nodeVar_, and deallocateNodeSons().

Here is the call graph for this function:

◆ setNodeVar()

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

Set the node variable.

Definition at line 114 of file internalNode.cpp.

114 {
116 _setNodeVar_(v);
117 }

References _nodeSons_, _nodeVar_, _setNodeVar_(), and deallocateNodeSons().

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 100 of file internalNode_inl.h.

100{ _nodeSons_[modality] = son; }
NodeId son(Idx modality) const
Returns the son at a given index.

References _nodeSons_, and son().

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 103 of file internalNode_inl.h.

103{ return _nodeSons_[modality]; }

References _nodeSons_.

Referenced by gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::_checkIsomorphism_(), gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::_compute_(), gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_compute_(), gum::StructuredPlaner< GUM_SCALAR >::_recurArgMaxCopy_(), gum::StructuredPlaner< GUM_SCALAR >::_recurExtractOptPol_(), gum::TreeOperator< GUM_SCALAR, COMBINEOPERATOR, TerminalNodePolicy >::_xPloreDT1_(), gum::TreeOperator< GUM_SCALAR, COMBINEOPERATOR, TerminalNodePolicy >::_xPloreDT2_(), gum::TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_xPloreVFunc_(), gum::MultiDimFunctionGraphGenerator::generate(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::get(), gum::StructuredPlaner< double >::initialize(), gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::migrateNode_(), gum::MultiDimFunctionGraph< double >::model(), gum::MultiDimFunctionGraphProjector< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::project(), gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::reduce_(), setSon(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot().

Here is the caller graph for this function:

Member Data Documentation

◆ _nodeParents_

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

The list of the node's parent.

Definition at line 147 of file internalNode.h.

Referenced by addParent(), parents(), parents(), and removeParent().

◆ _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 144 of file internalNode.h.

Referenced by InternalNode(), ~InternalNode(), _setNodeVar_(), setNode(), setNodeVar(), setSon(), and son().

◆ _nodeVar_

const DiscreteVariable* gum::InternalNode::_nodeVar_
private

Variable associated to such node.

Definition at line 127 of file internalNode.h.

Referenced by InternalNode(), InternalNode(), ~InternalNode(), _setNodeVar_(), nbSons(), nodeVar(), setNode(), and setNodeVar().


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