aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::prm::ClassDependencyGraph< GUM_SCALAR > Class Template Reference

This class represent the dependencies of all classes in a PRM<GUM_SCALAR>. More...

#include <agrum/PRM/classDependencyGraph.h>

Collaboration diagram for gum::prm::ClassDependencyGraph< GUM_SCALAR >:

Public Types

using EltPair
 Association between a class element and it's holding class.

Public Member Functions

Constructors and Destructor.
 ClassDependencyGraph (const PRM< GUM_SCALAR > &prm)
 Default constructor.
 ClassDependencyGraph (const ClassDependencyGraph< GUM_SCALAR > &source)
 Copy constructor.
 ~ClassDependencyGraph ()
 Destructor.
Getters & setters.
const DAGdag () const
 Returns a constant reference over the graph of the DAG representing the ClassDependencyGraph<GUM_SCALAR>.
const EltPairget (NodeId id) const
 Returns a constant reference over the element assiociated with the node id in the ClassDependencyGraph<GUM_SCALAR>.
NodeId get (const PRMClassElementContainer< GUM_SCALAR > &c, const PRMClassElement< GUM_SCALAR > &elt) const
 Returns the NodeId assign to the given PRMClassElement<GUM_SCALAR> of a given Class. Is is necessary to give both Class and PRMClassElement<GUM_SCALAR> because inherited PRMClassElement<GUM_SCALAR> are shared in the inheritance hierarchy.
const NodeProperty< Size > & modalities () const
 Returns a mapping between the ClassDependencyGraph<GUM_SCALAR>'s nodes and their modalities.

Private Types

using NodeMap
 Code shortcut.

Private Member Functions

void _buildGraph_ (const PRM< GUM_SCALAR > &prm)
 Build the class dependency graph.
void _addNode_ (const PRMClassElementContainer< GUM_SCALAR > *c, const PRMClassElement< GUM_SCALAR > &elt)
 Add nodes in graph while updating consequently all the mappings.
void _addArcs_ (const PRMClassElementContainer< GUM_SCALAR > &c, NodeId node, HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > &map)
 Add arcs in graph.

Private Attributes

DAG _graph_
 The graph itself.
NodeProperty< Size_modalitites_
 The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a Triangulation class over a ClassDependencyGraph<GUM_SCALAR>.
NodeProperty< EltPair * > _elt_map_
 Mapping between the nodes in graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
NodeMap _node_map_
 Map each Class to a HashTable mapping the Class's ClassElements to their assigned NodeId in graph.

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::ClassDependencyGraph< GUM_SCALAR >

This class represent the dependencies of all classes in a PRM<GUM_SCALAR>.

A Class Dependency Graph does listen to changes in it's PRM<GUM_SCALAR>.

Definition at line 66 of file classDependencyGraph.h.

Member Typedef Documentation

◆ EltPair

template<typename GUM_SCALAR>
using gum::prm::ClassDependencyGraph< GUM_SCALAR >::EltPair
Initial value:
std::pair< const PRMClassElementContainer< GUM_SCALAR >*,
Abstract class representing an element of PRM class.

Association between a class element and it's holding class.

Definition at line 69 of file classDependencyGraph.h.

◆ NodeMap

template<typename GUM_SCALAR>
using gum::prm::ClassDependencyGraph< GUM_SCALAR >::NodeMap
private
Initial value:

Code shortcut.

Definition at line 154 of file classDependencyGraph.h.

Constructor & Destructor Documentation

◆ ClassDependencyGraph() [1/2]

template<typename GUM_SCALAR>
INLINE gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph ( const PRM< GUM_SCALAR > & prm)

Default constructor.

Parameters
prmThe PRM<GUM_SCALAR> for which this ClassDependencyGraph<GUM_SCALAR> is constructed.

Definition at line 123 of file classDependencyGraph_tpl.h.

123 {
126 }
This class represent the dependencies of all classes in a PRM<GUM_SCALAR>.
void _buildGraph_(const PRM< GUM_SCALAR > &prm)
Build the class dependency graph.
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.

References ClassDependencyGraph(), and _buildGraph_().

Referenced by ClassDependencyGraph(), ClassDependencyGraph(), and ~ClassDependencyGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClassDependencyGraph() [2/2]

template<typename GUM_SCALAR>
INLINE gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph ( const ClassDependencyGraph< GUM_SCALAR > & source)

Copy constructor.

Definition at line 129 of file classDependencyGraph_tpl.h.

130 :
133
134 for (const auto& elt: source._node_map_) {
135 _node_map_.insert(
136 elt.first,
137 new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >(*elt.second));
138 }
139 }
NodeProperty< EltPair * > _elt_map_
Mapping between the nodes in graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
NodeProperty< Size > _modalitites_
The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a...
NodeMap _node_map_
Map each Class to a HashTable mapping the Class's ClassElements to their assigned NodeId in graph.

References ClassDependencyGraph(), _elt_map_, _graph_, _modalitites_, and _node_map_.

Here is the call graph for this function:

◆ ~ClassDependencyGraph()

template<typename GUM_SCALAR>
gum::prm::ClassDependencyGraph< GUM_SCALAR >::~ClassDependencyGraph ( )

Destructor.

Definition at line 56 of file classDependencyGraph_tpl.h.

56 {
58
59 for (const auto& elt: _node_map_)
60 delete elt.second;
61
62 for (const auto& elt: _elt_map_)
63 delete elt.second;
64 }

References ClassDependencyGraph(), _elt_map_, and _node_map_.

Here is the call graph for this function:

Member Function Documentation

◆ _addArcs_()

template<typename GUM_SCALAR>
void gum::prm::ClassDependencyGraph< GUM_SCALAR >::_addArcs_ ( const PRMClassElementContainer< GUM_SCALAR > & c,
NodeId node,
HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > & map )
private

Add arcs in graph.

Definition at line 93 of file classDependencyGraph_tpl.h.

96 {
97 switch (c.get(node).elt_type()) {
100 = static_cast< const PRMSlotChain< GUM_SCALAR >& >(c.get(node));
101
102 for (const auto chi: c.containerDag().children(node))
103 _graph_.addArc((*(_node_map_[&(sc.end())]))[&(sc.end().get(sc.lastElt().safeName()))],
104 map[&(c.get(chi))]);
105
106 break;
107 }
108
111 for (const auto chi: c.containerDag().children(node))
112 _graph_.addArc(map[&(c.get(node))], map[&(c.get(chi))]);
113
114 break;
115 }
116
117 default : { /* do nothing */ break;
118 }
119 }
120 }
const EltPair & get(NodeId id) const
Returns a constant reference over the element assiociated with the node id in the ClassDependencyGrap...

References _graph_, _node_map_, gum::ArcGraphPart::children(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::PRMSlotChain< GUM_SCALAR >::end(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, and gum::prm::PRMClassElement< GUM_SCALAR >::prm_slotchain.

Referenced by _buildGraph_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _addNode_()

template<typename GUM_SCALAR>
INLINE void gum::prm::ClassDependencyGraph< GUM_SCALAR >::_addNode_ ( const PRMClassElementContainer< GUM_SCALAR > * c,
const PRMClassElement< GUM_SCALAR > & elt )
private

Add nodes in graph while updating consequently all the mappings.

Definition at line 165 of file classDependencyGraph_tpl.h.

167 {
168 switch (elt.elt_type()) {
171 NodeId id = _graph_.addNode();
173 _node_map_[c]->insert(&elt, id);
174 _modalitites_.insert(id, elt.type().variable().domainSize());
175 break;
176 }
177
178 default : { /* do nothing */ break;
179 }
180 }
181 }

References _elt_map_, _graph_, _modalitites_, _node_map_, gum::DiscreteVariable::domainSize(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMClassElement< GUM_SCALAR >::prm_aggregate, gum::prm::PRMClassElement< GUM_SCALAR >::prm_attribute, gum::prm::PRMClassElement< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Referenced by _buildGraph_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _buildGraph_()

template<typename GUM_SCALAR>
void gum::prm::ClassDependencyGraph< GUM_SCALAR >::_buildGraph_ ( const PRM< GUM_SCALAR > & prm)
private

Build the class dependency graph.

Definition at line 68 of file classDependencyGraph_tpl.h.

68 {
69 // First we add all nodes
70 for (const auto ci: prm.classes()) {
72
73 for (const auto node: ci->containerDag().nodes())
75 }
76
77 for (const auto ii: prm.interfaces()) {
79
80 for (const auto node: ii->containerDag().nodes()) {
82 }
83 }
84
85 // Then we add the arcs
86 for (const auto cc: prm.classes())
87 for (const auto node: cc->containerDag().nodes())
89 }
void _addArcs_(const PRMClassElementContainer< GUM_SCALAR > &c, NodeId node, HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > &map)
Add arcs in graph.
void _addNode_(const PRMClassElementContainer< GUM_SCALAR > *c, const PRMClassElement< GUM_SCALAR > &elt)
Add nodes in graph while updating consequently all the mappings.

References _addArcs_(), _addNode_(), and _node_map_.

Referenced by ClassDependencyGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dag()

template<typename GUM_SCALAR>
INLINE const DAG & gum::prm::ClassDependencyGraph< GUM_SCALAR >::dag ( ) const

Returns a constant reference over the graph of the DAG representing the ClassDependencyGraph<GUM_SCALAR>.

Definition at line 142 of file classDependencyGraph_tpl.h.

142 {
143 return _graph_;
144 }

References _graph_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_initElimOrder_(), and gum::prm::SVED< GUM_SCALAR >::_initElimOrder_().

Here is the caller graph for this function:

◆ get() [1/2]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::ClassDependencyGraph< GUM_SCALAR >::get ( const PRMClassElementContainer< GUM_SCALAR > & c,
const PRMClassElement< GUM_SCALAR > & elt ) const

Returns the NodeId assign to the given PRMClassElement<GUM_SCALAR> of a given Class. Is is necessary to give both Class and PRMClassElement<GUM_SCALAR> because inherited PRMClassElement<GUM_SCALAR> are shared in the inheritance hierarchy.

Definition at line 154 of file classDependencyGraph_tpl.h.

155 {
156 return (*(_node_map_[&c]))[&elt];
157 }

References _node_map_.

◆ get() [2/2]

template<typename GUM_SCALAR>
INLINE const ClassDependencyGraph< GUM_SCALAR >::EltPair & gum::prm::ClassDependencyGraph< GUM_SCALAR >::get ( NodeId id) const

Returns a constant reference over the element assiociated with the node id in the ClassDependencyGraph<GUM_SCALAR>.

Exceptions
NotFoundRaised if no nodes matches id.

Definition at line 148 of file classDependencyGraph_tpl.h.

148 {
149 return *(_elt_map_[id]);
150 }

References _elt_map_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_initElimOrder_(), and gum::prm::SVED< GUM_SCALAR >::_initElimOrder_().

Here is the caller graph for this function:

◆ modalities()

template<typename GUM_SCALAR>
INLINE const NodeProperty< Size > & gum::prm::ClassDependencyGraph< GUM_SCALAR >::modalities ( ) const

Returns a mapping between the ClassDependencyGraph<GUM_SCALAR>'s nodes and their modalities.

Definition at line 160 of file classDependencyGraph_tpl.h.

160 {
161 return _modalitites_;
162 }

References _modalitites_.

Member Data Documentation

◆ _elt_map_

template<typename GUM_SCALAR>
NodeProperty< EltPair* > gum::prm::ClassDependencyGraph< GUM_SCALAR >::_elt_map_
private

Mapping between the nodes in graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.

Definition at line 151 of file classDependencyGraph.h.

Referenced by ClassDependencyGraph(), ~ClassDependencyGraph(), _addNode_(), and get().

◆ _graph_

template<typename GUM_SCALAR>
DAG gum::prm::ClassDependencyGraph< GUM_SCALAR >::_graph_
private

The graph itself.

Definition at line 137 of file classDependencyGraph.h.

Referenced by ClassDependencyGraph(), _addArcs_(), _addNode_(), and dag().

◆ _modalitites_

template<typename GUM_SCALAR>
NodeProperty< Size > gum::prm::ClassDependencyGraph< GUM_SCALAR >::_modalitites_
private

The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a Triangulation class over a ClassDependencyGraph<GUM_SCALAR>.

Definition at line 144 of file classDependencyGraph.h.

Referenced by ClassDependencyGraph(), _addNode_(), and modalities().

◆ _node_map_

template<typename GUM_SCALAR>
NodeMap gum::prm::ClassDependencyGraph< GUM_SCALAR >::_node_map_
private

Map each Class to a HashTable mapping the Class's ClassElements to their assigned NodeId in graph.

Definition at line 160 of file classDependencyGraph.h.

Referenced by ClassDependencyGraph(), ~ClassDependencyGraph(), _addArcs_(), _addNode_(), _buildGraph_(), and get().


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