![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Virtual base class for PGMs using a undirected graph. More...
#include <agrum/base/graphicalModels/UGmodel.h>
Public Member Functions | |
| bool | hasSameStructure (const UGmodel &other) |
| check if nodes X and nodes Y are independent given nodes Z | |
| NodeSet | family (const NodeId id) const final |
| returns the the node as a NodeSet (in mixed graph : family is the node and its parents | |
| NodeSet | family (const std::string &name) const final |
| double | log10DomainSize () const |
Constructors / Destructors | |
| UGmodel () | |
| Default constructor. | |
| virtual | ~UGmodel () |
| Destructor. | |
| UGmodel (const UGmodel &source) | |
| Copy constructor. | |
Variable manipulation methods. | |
| const UndiGraph & | graph () const |
| Returns a constant reference to the dag of this Bayes Net. | |
| virtual Size | size () const final |
| Returns the number of variables in this Directed Graphical Model. | |
| Size | sizeEdges () const |
| Returns the number of arcs in this Directed Graphical Model. | |
| const NodeGraphPart & | nodes () const final |
| Returns a constant reference to the dag of this Bayes Net. | |
| bool | exists (NodeId node) const final |
| Return true if this node exists in this graphical model. | |
| bool | exists (const std::string &name) const final |
| Returns a constant reference to the dag of this Bayes Net. | |
Edge manipulation methods. | |
| const EdgeSet & | edges () const |
| return true if the edge node1-node2 exists in the UGModel | |
| bool | existsEdge (const NodeId node1, const NodeId node2) const |
| return true if the edge node1-node2 exists in the UGModel | |
| bool | existsEdge (const std::string &name1, const std::string &name2) const |
| return true if the edge node1-node2 exists in the UGModel | |
| const NodeSet & | neighbours (const NodeId id) const |
| returns the neighbours of a node as set of nodes | |
| const NodeSet & | neighbours (const std::string &name) const |
| return true if the edge node1-node2 exists in the UGModel | |
| bool | isIndependent (NodeId X, NodeId Y, const NodeSet &Z) const final |
| check if X and Y are independent given Z | |
| bool | isIndependent (const NodeSet &X, const NodeSet &Y, const NodeSet &Z) const final |
| check if nodes X and nodes Y are independent given nodes Z | |
| bool | isIndependent (const std::string &Xname, const std::string &Yname, const std::vector< std::string > &Znames) const |
| return true if the edge node1-node2 exists in the UGModel | |
| bool | isIndependent (const std::vector< std::string > &Xnames, const std::vector< std::string > &Ynames, const std::vector< std::string > &Znames) const |
| return true if the edge node1-node2 exists in the UGModel | |
Getter and setters | |
| const std::string & | property (const std::string &name) const |
| Return the value of the property name of this GraphicalModel. | |
| const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
| Return the value of the property name of this GraphicalModel. | |
| void | setProperty (const std::string &name, const std::string &value) |
| Add or change a property of this GraphicalModel. | |
| std::vector< std::string > | properties () const |
| List of all the properties. | |
Variable manipulation methods. | |
| virtual const VariableNodeMap & | variableNodeMap () const =0 |
| Returns a constant reference to the VariableNodeMap of this Graphical Model. | |
| virtual bool | empty () const |
| Return true if this graphical model is empty. | |
| std::vector< std::string > | names (const std::vector< NodeId > &ids) const |
| transform a vector of NodeId in a vector of names | |
| std::vector< std::string > | names (const NodeSet &ids) const |
| transform a NodeSet in a vector of names | |
| std::vector< NodeId > | ids (const std::vector< std::string > &names) const |
| transform a vector of names into a vector of nodeId | |
| NodeSet | nodeset (const std::vector< std::string > &names) const |
| transform a vector of names into a NodeSet | |
| gum::VariableSet | variables (const std::vector< std::string > &l) const |
| transform a vector of names into a VariableeSet | |
| gum::VariableSet | variables (const NodeSet &ids) const |
| transform a vector of NodeId into a VariableeSet | |
| Instantiation | completeInstantiation () const |
| Get an instantiation over all the variables of the model. | |
| virtual const DiscreteVariable & | variable (NodeId id) const =0 |
| Returns a constant reference over a variable given it's node id. | |
| virtual NodeId | nodeId (const DiscreteVariable &var) const =0 |
| Return id node src discrete var pointer. | |
| virtual NodeId | idFromName (const std::string &name) const =0 |
| Getter by name. | |
| virtual const DiscreteVariable & | variableFromName (const std::string &name) const =0 |
| Getter by name. | |
Static Public Member Functions | |
| static void | spaceCplxToStream (std::stringstream &s, double dSize, int dim, Size usedMem) |
| send to the stream the space complexity with 3 parametrs | |
Protected Member Functions | |
| UGmodel & | operator= (const UGmodel &source) |
| Private copy operator. | |
Protected Attributes | |
| UndiGraph | graph_ |
| The DAG of this Directed Graphical Model. | |
Private Member Functions | |
| const HashTable< std::string, std::string > & | _properties_ () const |
| Return the properties of this Directed Graphical Model. | |
Private Attributes | |
| HashTable< std::string, std::string > | _propertiesMap_ |
| The properties of this Directed Graphical Model. | |
| gum::UGmodel::UGmodel | ( | ) |
Default constructor.
Definition at line 49 of file UGmodel.cpp.
References UGmodel().
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), UGmodel(), UGmodel(), ~UGmodel(), hasSameStructure(), and operator=().
|
virtual |
Destructor.
Definition at line 56 of file UGmodel.cpp.
References UGmodel().
| gum::UGmodel::UGmodel | ( | const UGmodel & | source | ) |
Copy constructor.
Do nothing.
Definition at line 54 of file UGmodel.cpp.
References UGmodel(), and graph_.
|
privateinherited |
Return the properties of this Directed Graphical Model.
Definition at line 70 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by property().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 106 of file graphicalModel_inl.h.
References nodes().
| INLINE const EdgeSet & gum::UGmodel::edges | ( | ) | const |
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 65 of file UGmodel_inl.h.
References graph_.
Referenced by hasSameStructure().
|
virtualinherited |
Return true if this graphical model is empty.
Definition at line 116 of file graphicalModel_inl.h.
References size().
Referenced by gum::IBayesNet< GUM_SCALAR >::check(), and gum::BayesNet< GUM_SCALAR >::clear().
|
finalvirtual |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 83 of file UGmodel_inl.h.
References exists(), and gum::GraphicalModel::idFromName().
Return true if this node exists in this graphical model.
Implements gum::GraphicalModel.
Definition at line 81 of file UGmodel_inl.h.
References graph_.
Referenced by exists().
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 67 of file UGmodel_inl.h.
References graph_.
Referenced by existsEdge().
| INLINE bool gum::UGmodel::existsEdge | ( | const std::string & | name1, |
| const std::string & | name2 ) const |
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 71 of file UGmodel_inl.h.
References existsEdge(), and gum::GraphicalModel::idFromName().
returns the the node as a NodeSet (in mixed graph : family is the node and its parents
| id | the node which is the head of an arc with the returned nodes |
| name | the name of the node the node which is the head of an arc with the returned nodes |
Implements gum::GraphicalModel.
Definition at line 99 of file UGmodel_inl.h.
Referenced by family().
|
finalvirtual |
Implements gum::GraphicalModel.
Definition at line 105 of file UGmodel_inl.h.
References family(), and gum::GraphicalModel::idFromName().
| INLINE const UndiGraph & gum::UGmodel::graph | ( | ) | const |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 57 of file UGmodel_inl.h.
References graph_.
Referenced by gum::MarginalTargetedMRFInference< GUM_SCALAR >::MarginalTargetedMRFInference(), isIndependent(), isIndependent(), size(), and gum::IMarkovRandomField< GUM_SCALAR >::toString().
check if nodes X and nodes Y are independent given nodes Z
Definition at line 70 of file UGmodel.cpp.
References UGmodel(), edges(), gum::Set< Key >::exists(), gum::GraphicalModel::idFromName(), nodes(), size(), sizeEdges(), and gum::GraphicalModel::variable().
|
pure virtualinherited |
Getter by name.
| NotFound | if no such name exists in the graph. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::IMarkovRandomField< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by gum::DAGmodel::ancestors(), gum::DAGmodel::children(), gum::IBayesNet< double >::children(), gum::DAGmodel::descendants(), gum::UGmodel::exists(), gum::DAGmodel::existsArc(), gum::UGmodel::existsEdge(), gum::DAGmodel::family(), gum::UGmodel::family(), gum::DAGmodel::hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), gum::UGmodel::hasSameStructure(), gum::DAGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::UGmodel::neighbours(), nodeset(), and gum::DAGmodel::parents().
|
inherited |
transform a vector of names into a vector of nodeId
Definition at line 139 of file graphicalModel_inl.h.
References names().
Referenced by gum::DAGmodel::children(), exists(), names(), and gum::DAGmodel::parents().
|
finalvirtual |
check if nodes X and nodes Y are independent given nodes Z
Implements gum::GraphicalModel.
Definition at line 95 of file UGmodel_inl.h.
References graph(), and gum::EdgeGraphPart::hasUndirectedPath().
|
inline |
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 144 of file UGmodel.h.
References gum::GraphicalModel::idFromName(), isIndependent(), and gum::GraphicalModel::nodeset().
|
inline |
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 150 of file UGmodel.h.
References isIndependent(), and gum::GraphicalModel::nodeset().
|
finalvirtual |
check if X and Y are independent given Z
Implements gum::GraphicalModel.
Definition at line 91 of file UGmodel_inl.h.
References graph(), and gum::EdgeGraphPart::hasUndirectedPath().
Referenced by isIndependent(), and isIndependent().
|
inherited |
Definition at line 95 of file graphicalModel_inl.h.
References nodes().
Referenced by gum::IBayesNet< GUM_SCALAR >::toString(), gum::IMarkovRandomField< GUM_SCALAR >::toString(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
|
inherited |
transform a NodeSet in a vector of names
Definition at line 129 of file graphicalModel_inl.h.
|
inherited |
transform a vector of NodeId in a vector of names
Definition at line 119 of file graphicalModel_inl.h.
References ids(), and variableNodeMap().
Referenced by gum::DAGmodel::children(), exists(), ids(), nodeset(), and gum::DAGmodel::parents().
returns the neighbours of a node as set of nodes
Note that the set of nodes returned may be empty if no edge within the EdgeGraphPart contains the given node.
| id | the node toward which the edge returned are pointing |
Definition at line 75 of file UGmodel_inl.h.
References graph_.
Referenced by neighbours(), and gum::IMarkovRandomField< GUM_SCALAR >::toDot().
| INLINE const NodeSet & gum::UGmodel::neighbours | ( | const std::string & | name | ) | const |
return true if the edge node1-node2 exists in the UGModel
| node1 | the nodeId (or the name) of the node1 |
| node2 | the nodeId (or the name) of the node2 |
Definition at line 77 of file UGmodel_inl.h.
References gum::GraphicalModel::idFromName(), and neighbours().
|
pure virtualinherited |
Return id node src discrete var pointer.
| NotFound | If no variable matches var. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::IMarkovRandomField< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
finalvirtual |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 89 of file UGmodel_inl.h.
References graph_.
Referenced by hasSameStructure(), gum::IMarkovRandomField< GUM_SCALAR >::maxVarDomainSize(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
inherited |
transform a vector of names into a NodeSet
Definition at line 60 of file graphicalModel.cpp.
References idFromName(), gum::Set< Key >::insert(), and names().
Referenced by gum::IBayesNet< double >::children(), gum::IBayesNet< double >::children(), gum::DAGmodel::isIndependent(), gum::DAGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::DAGmodel::moralizedAncestralGraph(), and gum::DAGmodel::parents().
Private copy operator.
Definition at line 61 of file UGmodel.cpp.
References UGmodel(), graph_, and gum::GraphicalModel::operator=().
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::operator=().
|
inherited |
List of all the properties.
Definition at line 81 of file graphicalModel_inl.h.
References _propertiesMap_.
|
inherited |
Return the value of the property name of this GraphicalModel.
| NotFound | Raised if no name property is found. |
Definition at line 60 of file graphicalModel_inl.h.
References _properties_(), and GUM_ERROR.
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
inherited |
Return the value of the property name of this GraphicalModel.
return byDefault if the property name is not found
Definition at line 75 of file graphicalModel_inl.h.
References _propertiesMap_.
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 89 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by gum::IBayesNet< GUM_SCALAR >::IBayesNet(), gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().
|
finalvirtual |
Returns the number of variables in this Directed Graphical Model.
Implements gum::GraphicalModel.
Definition at line 60 of file UGmodel_inl.h.
References graph(), and gum::NodeGraphPart::size().
Referenced by hasSameStructure(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toString().
| INLINE Size gum::UGmodel::sizeEdges | ( | ) | const |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 63 of file UGmodel_inl.h.
References graph_.
Referenced by hasSameStructure(), and gum::IMarkovRandomField< GUM_SCALAR >::operator==().
|
staticinherited |
send to the stream the space complexity with 3 parametrs
| s | the stream |
| dSize | the log10domainSize |
| dim | the dimension |
| usedMem | the memory needed for the params |
Definition at line 69 of file graphicalModel.cpp.
Referenced by gum::IBayesNet< GUM_SCALAR >::toString().
|
pure virtualinherited |
Returns a constant reference over a variable given it's node id.
| NotFound | If no variable's id matches varId. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::IMarkovRandomField< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by gum::DAGmodel::hasSameStructure(), and gum::UGmodel::hasSameStructure().
|
pure virtualinherited |
Getter by name.
| NotFound | if no such name exists in the graph. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::IMarkovRandomField< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
pure virtualinherited |
Returns a constant reference to the VariableNodeMap of this Graphical Model.
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::IMarkovRandomField< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by gum::IBayesNet< double >::empty(), names(), variables(), and variables().
|
inherited |
transform a vector of NodeId into a VariableeSet
Definition at line 160 of file graphicalModel_inl.h.
References gum::VariableNodeMap::get(), gum::Set< Key >::insert(), and variableNodeMap().
|
inherited |
transform a vector of names into a VariableeSet
Definition at line 150 of file graphicalModel_inl.h.
References variableNodeMap().
|
privateinherited |
The properties of this Directed Graphical Model.
Definition at line 236 of file graphicalModel.h.
Referenced by _properties_(), operator=(), properties(), propertyWithDefault(), and setProperty().
|
protected |
The DAG of this Directed Graphical Model.
Definition at line 182 of file UGmodel.h.
Referenced by UGmodel(), gum::IMarkovRandomField< GUM_SCALAR >::_minimalCondSetVisit_(), edges(), exists(), existsEdge(), graph(), gum::IMarkovRandomField< GUM_SCALAR >::minimalCondSet(), neighbours(), nodes(), operator=(), and sizeEdges().