aGrUM  0.18.1
a C++ library for (probabilistic) graphical models
gum::VariableNodeMap Class Reference

Container used to map discrete variables with nodes. More...

#include <variableNodeMap.h>

+ Collaboration diagram for gum::VariableNodeMap:

Public Member Functions

Constructors / Destructors
 VariableNodeMap ()
 Default constructor. More...
 
 VariableNodeMap (const VariableNodeMap &source)
 Copy constructor Proceed a deep copy: all variables are copied but keep the same node id. More...
 
 ~VariableNodeMap ()
 Destructor. More...
 
VariableNodeMapoperator= (const VariableNodeMap &source)
 Copy operator. More...
 
Getters and setters.
const DiscreteVariableget (NodeId id) const
 Returns a discrete variable given it's node id. More...
 
NodeId get (const DiscreteVariable &var) const
 Returns a node id given it's variable. More...
 
bool exists (NodeId id) const
 Return true if id matches a node. More...
 
bool exists (const DiscreteVariable &var) const
 Return true if var matches a node. More...
 
NodeId insert (NodeId id, const DiscreteVariable &var)
 Maps id with var. More...
 
void erase (NodeId id)
 Removes a var and it's id of this mapping. The pointer is deleted. More...
 
void erase (const DiscreteVariable &var)
 Removes a var and it's id of this mapping. The pointer is deleted. More...
 
void changeName (NodeId id, const std::string &new_name)
 we allow the user to change the name of a variable More...
 
void clear ()
 removes all the associations More...
 
const std::string toString () const
 friendly displays the content of the VariableNodeMap More...
 
const std::string & name (NodeId id) const
 Returns the name of a variable given its id. More...
 
const std::string & name (const DiscreteVariable &var) const
 Returns the name of a variable. More...
 
Operators.
const DiscreteVariableoperator[] (NodeId id) const
 Returns a discrete variable given it's node id. More...
 
NodeId operator[] (const DiscreteVariable &var) const
 Returns a node id given it's variable. More...
 
Accessor by name
NodeId idFromName (const std::string &name) const
 
const DiscreteVariablevariableFromName (const std::string &name) const
 

Detailed Description

Container used to map discrete variables with nodes.

Warning
VariableNodeMap ensures that every name of variable is unique in the container.

Definition at line 50 of file variableNodeMap.h.

Constructor & Destructor Documentation

◆ VariableNodeMap() [1/2]

gum::VariableNodeMap::VariableNodeMap ( )

Default constructor.

◆ VariableNodeMap() [2/2]

gum::VariableNodeMap::VariableNodeMap ( const VariableNodeMap source)

Copy constructor Proceed a deep copy: all variables are copied but keep the same node id.

◆ ~VariableNodeMap()

gum::VariableNodeMap::~VariableNodeMap ( )

Destructor.

Member Function Documentation

◆ changeName()

void gum::VariableNodeMap::changeName ( NodeId  id,
const std::string &  new_name 
)

we allow the user to change the name of a variable

Exceptions
DuplicateLabelif this name already exists
NotFoundRaised if no nodes matches id.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::changeVariableName().

+ Here is the caller graph for this function:

◆ clear()

void gum::VariableNodeMap::clear ( )

removes all the associations

◆ copy__()

void gum::VariableNodeMap::copy__ ( const VariableNodeMap source)
private

effectively do the copy (for copy constructor or operator=)

◆ erase() [1/2]

void gum::VariableNodeMap::erase ( NodeId  id)

Removes a var and it's id of this mapping. The pointer is deleted.

Exceptions
NotFoundRaised if no nodes matches id.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::erase().

+ Here is the caller graph for this function:

◆ erase() [2/2]

void gum::VariableNodeMap::erase ( const DiscreteVariable var)

Removes a var and it's id of this mapping. The pointer is deleted.

Exceptions
NotFoundRaised if no nodes matches id.

◆ exists() [1/2]

bool gum::VariableNodeMap::exists ( NodeId  id) const

Return true if id matches a node.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::erase().

+ Here is the caller graph for this function:

◆ exists() [2/2]

bool gum::VariableNodeMap::exists ( const DiscreteVariable var) const

Return true if var matches a node.

◆ get() [1/2]

const DiscreteVariable& gum::VariableNodeMap::get ( NodeId  id) const

Returns a discrete variable given it's node id.

Exceptions
NotFoundRaised if no nodes matches id.

Referenced by gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), and gum::InfluenceDiagram< GUM_SCALAR >::nodeId().

+ Here is the caller graph for this function:

◆ get() [2/2]

NodeId gum::VariableNodeMap::get ( const DiscreteVariable var) const

Returns a node id given it's variable.

Exceptions
NotFoundRaised if no nodes matches var.

◆ idFromName()

NodeId gum::VariableNodeMap::idFromName ( const std::string &  name) const
Exceptions
NotFoundif no such name exists in the graph.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::idFromName().

+ Here is the caller graph for this function:

◆ insert()

NodeId gum::VariableNodeMap::insert ( NodeId  id,
const DiscreteVariable var 
)

Maps id with var.

Warning
Var is added by copy.
Exceptions
DuplicateLabelif this name already exists
DuplicateElementif this id already exists
Returns
Returns id (useful in some case);

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::addNode_().

+ Here is the caller graph for this function:

◆ name() [1/2]

const std::string& gum::VariableNodeMap::name ( NodeId  id) const

Returns the name of a variable given its id.

Parameters
idThe variable's id.
Returns
id's name.
Exceptions
NotFoundRaised if no variable matches id.

◆ name() [2/2]

const std::string& gum::VariableNodeMap::name ( const DiscreteVariable var) const

Returns the name of a variable.

Parameters
varThe variable.
Returns
var's name.
Exceptions
NotFoundRaised if var is not in this VariableNodeMap.

◆ operator=()

VariableNodeMap& gum::VariableNodeMap::operator= ( const VariableNodeMap source)

Copy operator.

◆ operator[]() [1/2]

const DiscreteVariable& gum::VariableNodeMap::operator[] ( NodeId  id) const

Returns a discrete variable given it's node id.

Exceptions
NotFoundRaised if no nodes matches id.

◆ operator[]() [2/2]

NodeId gum::VariableNodeMap::operator[] ( const DiscreteVariable var) const

Returns a node id given it's variable.

Exceptions
NotFoundRaised if no nodes matches var.

◆ toString()

const std::string gum::VariableNodeMap::toString ( ) const

friendly displays the content of the VariableNodeMap

◆ variableFromName()

const DiscreteVariable& gum::VariableNodeMap::variableFromName ( const std::string &  name) const
Exceptions
NotFoundif no such name exists in the graph.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::variableFromName().

+ Here is the caller graph for this function:

Member Data Documentation

◆ names2nodes__

Bijection< std::string, NodeId > gum::VariableNodeMap::names2nodes__
private

HashTable for easely find an id from a name.

Definition at line 169 of file variableNodeMap.h.

◆ nodes2vars__

Bijection< NodeId, const DiscreteVariable* > gum::VariableNodeMap::nodes2vars__
private

Bijection between the node's NodeIds and the variables.

Definition at line 166 of file variableNodeMap.h.


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