35 template <
typename GUM_SCALAR >
43 this->_dag.addNodeWithId(elt.
id());
44 this->__varNodeMap.insert(&(elt.
type().
variable()), &elt);
53 this->_dag.addArc(arc.tail(), arc.head());
60 template <
typename GUM_SCALAR >
69 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
82 template <
typename GUM_SCALAR >
94 template <
typename GUM_SCALAR >
97 return __get(varId).cpf();
100 template <
typename GUM_SCALAR >
106 template <
typename GUM_SCALAR >
109 return __get(
id).type().variable();
112 template <
typename GUM_SCALAR >
118 template <
typename GUM_SCALAR >
121 return __get(name).id();
124 template <
typename GUM_SCALAR >
126 const std::string& name)
const {
127 return __get(name).type().variable();
130 template <
typename GUM_SCALAR >
140 template <
typename GUM_SCALAR >
150 template <
typename GUM_SCALAR >
154 for (
const auto node : this->
nodes()) {
162 template <
typename GUM_SCALAR >
164 std::string tab =
" ";
165 std::stringstream output;
166 output <<
"digraph \"";
167 output <<
__class->name() <<
"\" {" << std::endl;
169 for (
const auto node : this->
nodes()) {
171 for (
const auto chi : this->
children(node)) {
172 output << tab <<
"\"" <<
variable(node).
name() <<
"\" -> ";
173 output <<
"\"" <<
variable(chi).
name() <<
"\";" << std::endl;
176 output << tab <<
"\"" <<
variable(node).
name() <<
"\";" << std::endl;
180 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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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>.