32 template <
typename GUM_SCALAR >
40 this->_dag.addNodeWithId(elt.
id());
41 this->__varNodeMap.insert(&(elt.
type().
variable()), &elt);
50 this->_dag.addArc(arc.tail(), arc.head());
57 template <
typename GUM_SCALAR >
66 template <
typename GUM_SCALAR >
74 template <
typename GUM_SCALAR >
79 template <
typename GUM_SCALAR >
91 template <
typename GUM_SCALAR >
94 return __get(varId).cpf();
97 template <
typename GUM_SCALAR >
103 template <
typename GUM_SCALAR >
106 return __get(
id).type().variable();
109 template <
typename GUM_SCALAR >
115 template <
typename GUM_SCALAR >
118 return __get(name).id();
121 template <
typename GUM_SCALAR >
123 const std::string& name)
const {
124 return __get(name).type().variable();
127 template <
typename GUM_SCALAR >
137 template <
typename GUM_SCALAR >
147 template <
typename GUM_SCALAR >
151 for (
const auto node : this->
nodes()) {
159 template <
typename GUM_SCALAR >
161 std::string tab =
" ";
162 std::stringstream output;
163 output <<
"digraph \"";
164 output <<
__class->name() <<
"\" {" << std::endl;
166 for (
const auto node : this->
nodes()) {
168 for (
const auto chi : this->
children(node)) {
169 output << tab <<
"\"" <<
variable(node).
name() <<
"\" -> ";
170 output <<
"\"" <<
variable(chi).
name() <<
"\";" << std::endl;
173 output << tab <<
"\"" <<
variable(node).
name() <<
"\";" << std::endl;
177 output <<
"}" << std::endl;
aGrUM's Potential is a multi-dimensional array with tensor operators.
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
void __init(const PRMClass< GUM_SCALAR > &c)
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
aGrUM's inline/outline selection
Container used to map discrete variables with nodes.
Abstract class representing an element of PRM class.
const PRMClassElement< GUM_SCALAR > & __get(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute.
const PRMClass< GUM_SCALAR > * __class
The PRMClassElementContainer decorated by this.
NodeProperty< Size > __modalities
IBayesNet< GUM_SCALAR > & operator=(const IBayesNet< GUM_SCALAR > &source)
Copy operator.
bool exists(const NodeId id) const
alias for existsNode
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
gum is the global namespace for all aGrUM entities
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
The class for generic Hash Tables.
ClassBayesNet(const PRMClass< GUM_SCALAR > &c)
Default constructor.
Headers of ClassBayesNet<GUM_SCALAR>.
Size size() const
Returns the number of variables in this Directed Graphical Model.
DAG _dag
The DAG of this Directed Graphical Model.
This class decorates a gum::prm::Class<GUM_SCALAR> has an IBaseBayesNet.
const NodeGraphPart & nodes() const
Returns a constant reference to the dag of this Bayes Net.
PRMClassElement< GUM_SCALAR > & get(NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
virtual ~ClassBayesNet()
Destructor.
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
NodeId id() const
Returns the NodeId of this element in it's class DAG.
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
virtual std::string toDot() const
std::size_t Size
In aGrUM, hashed values are unsigned long int.
const std::string & name() const
returns the name of the variable
ClassBayesNet< GUM_SCALAR > & operator=(const ClassBayesNet< GUM_SCALAR > &from)
Copy operator.
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
Size NodeId
Type for node ids.
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::modalities().
HashTable< const DiscreteVariable *, const PRMClassElement< GUM_SCALAR > *> __varNodeMap
Mapping between DiscreteVariable and their NodeId.
#define GUM_ERROR(type, msg)
virtual const Potential< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a node in this ClassBayesNet<GUM_SCALAR>.