![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Container used to map discrete variables with nodes. More...
#include <variableNodeMap.h>
Public Member Functions | |
Constructors / Destructors | |
| VariableNodeMap () | |
| Default constructor. | |
| VariableNodeMap (const VariableNodeMap &source) | |
| Copy constructor Proceed a deep copy: all variables are copied but keep the same node id. | |
| ~VariableNodeMap () | |
| Destructor. | |
| VariableNodeMap & | operator= (const VariableNodeMap &source) |
| Copy operator. | |
Getters and setters. | |
| const DiscreteVariable & | get (NodeId id) const |
| Returns a discrete variable given it's node id. | |
| NodeId | get (const DiscreteVariable &var) const |
| Returns a node id given it's variable. | |
| bool | exists (NodeId id) const |
| Return true if id matches a node. | |
| bool | exists (const DiscreteVariable &var) const |
| Return true if var matches a node. | |
| NodeId | insert (NodeId id, const DiscreteVariable &var) |
| Maps id with var. | |
| void | erase (NodeId id) |
| Removes a var and it's id of this mapping. The pointer is deleted. | |
| void | erase (const DiscreteVariable &var) |
| Removes a var and it's id of this mapping. The pointer is deleted. | |
| void | changeName (NodeId id, const std::string &new_name) |
| we allow the user to change the name of a variable | |
| void | clear () |
| removes all the associations | |
| Size | size () const |
| give the size | |
| std::string | toString () const |
| friendly displays the content of the VariableNodeMap | |
| const std::string & | name (NodeId id) const |
| Returns the name of a variable given its id. | |
| const std::string & | name (const DiscreteVariable &var) const |
| Returns the name of a variable. | |
Operators. | |
| const DiscreteVariable & | operator[] (NodeId id) const |
| Returns a discrete variable given it's node id. | |
| NodeId | operator[] (const DiscreteVariable &var) const |
| Returns a node id given it's variable. | |
Accessor by name | |
| NodeId | idFromName (const std::string &name) const |
| const DiscreteVariable & | variableFromName (const std::string &name) const |
Private Member Functions | |
| void | _copy_ (const VariableNodeMap &source) |
| effectively do the copy (for copy constructor or operator=) | |
Private Attributes | |
| Bijection< NodeId, const DiscreteVariable * > | _nodes2vars_ |
| Bijection between the node's NodeIds and the variables. | |
| Bijection< std::string, NodeId > | _names2nodes_ |
| HashTable for easely find an id from a name. | |
Container used to map discrete variables with nodes.
Definition at line 68 of file variableNodeMap.h.
| gum::VariableNodeMap::VariableNodeMap | ( | ) |
Default constructor.
Referenced by VariableNodeMap(), _copy_(), and operator=().
| gum::VariableNodeMap::VariableNodeMap | ( | const VariableNodeMap & | source | ) |
Copy constructor Proceed a deep copy: all variables are copied but keep the same node id.
References VariableNodeMap().
| gum::VariableNodeMap::~VariableNodeMap | ( | ) |
Destructor.
|
private |
effectively do the copy (for copy constructor or operator=)
References VariableNodeMap().
| void gum::VariableNodeMap::changeName | ( | NodeId | id, |
| const std::string & | new_name ) |
we allow the user to change the name of a variable
| DuplicateLabel | if this name already exists |
| NotFound | Raised if no nodes matches id. |
| void gum::VariableNodeMap::clear | ( | ) |
removes all the associations
| void gum::VariableNodeMap::erase | ( | const DiscreteVariable & | var | ) |
Removes a var and it's id of this mapping. The pointer is deleted.
| NotFound | Raised if no nodes matches id. |
| void gum::VariableNodeMap::erase | ( | NodeId | id | ) |
Removes a var and it's id of this mapping. The pointer is deleted.
| NotFound | Raised if no nodes matches id. |
| bool gum::VariableNodeMap::exists | ( | const DiscreteVariable & | var | ) | const |
Return true if var matches a node.
| NodeId gum::VariableNodeMap::get | ( | const DiscreteVariable & | var | ) | const |
Returns a node id given it's variable.
| NotFound | Raised if no nodes matches var. |
| const DiscreteVariable & gum::VariableNodeMap::get | ( | NodeId | id | ) | const |
Returns a discrete variable given it's node id.
| NotFound | Raised if no nodes matches id. |
Referenced by gum::learning::DAG2BNLearner::createBNwithEM(), and gum::GraphicalModel::variables().
| NodeId gum::VariableNodeMap::idFromName | ( | const std::string & | name | ) | const |
| NodeId gum::VariableNodeMap::insert | ( | NodeId | id, |
| const DiscreteVariable & | var ) |
Maps id with var.
| DuplicateLabel | if this name already exists |
| DuplicateElement | if this id already exists |
| const std::string & gum::VariableNodeMap::name | ( | const DiscreteVariable & | var | ) | const |
Returns the name of a variable.
| var | The variable. |
| NotFound | Raised if var is not in this VariableNodeMap. |
| const std::string & gum::VariableNodeMap::name | ( | NodeId | id | ) | const |
Returns the name of a variable given its id.
| id | The variable's id. |
| NotFound | Raised if no variable matches id. |
Referenced by gum::IBayesNet< double >::empty(), idFromName(), and variableFromName().
| VariableNodeMap & gum::VariableNodeMap::operator= | ( | const VariableNodeMap & | source | ) |
| NodeId gum::VariableNodeMap::operator[] | ( | const DiscreteVariable & | var | ) | const |
Returns a node id given it's variable.
| NotFound | Raised if no nodes matches var. |
| const DiscreteVariable & gum::VariableNodeMap::operator[] | ( | NodeId | id | ) | const |
Returns a discrete variable given it's node id.
| NotFound | Raised if no nodes matches id. |
| Size gum::VariableNodeMap::size | ( | ) | const |
give the size
| std::string gum::VariableNodeMap::toString | ( | ) | const |
friendly displays the content of the VariableNodeMap
| const DiscreteVariable & gum::VariableNodeMap::variableFromName | ( | const std::string & | name | ) | const |
| NotFound | if no such name exists in the graph. |
References name().
Referenced by gum::IBayesNet< double >::ids().
HashTable for easely find an id from a name.
Definition at line 190 of file variableNodeMap.h.
|
private |
Bijection between the node's NodeIds and the variables.
Definition at line 187 of file variableNodeMap.h.