aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
classDependencyGraph.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
49
#ifndef GUM_CLASS_DEPENDENCY_GRAPH_H
50
#define GUM_CLASS_DEPENDENCY_GRAPH_H
51
52
#include <
agrum/PRM/PRM.h
>
53
54
namespace
gum
{
55
namespace
prm
{
56
65
template
< GUM_Numeric GUM_SCALAR >
66
class
ClassDependencyGraph
{
67
public
:
69
using
EltPair
= std::pair< const PRMClassElementContainer< GUM_SCALAR >*,
70
const
PRMClassElement< GUM_SCALAR >
* >;
71
72
// ========================================================================
74
// ========================================================================
76
80
ClassDependencyGraph
(
const
PRM< GUM_SCALAR >
&
prm
);
81
83
ClassDependencyGraph
(
const
ClassDependencyGraph< GUM_SCALAR >
& source);
84
86
~ClassDependencyGraph
();
87
89
// ========================================================================
91
// ========================================================================
93
96
const
DAG
&
internalDag
()
const
;
97
102
const
EltPair
&
get
(
NodeId
id
)
const
;
103
112
NodeId
get
(
const
PRMClassElementContainer< GUM_SCALAR >
& c,
113
const
PRMClassElement< GUM_SCALAR >
& elt)
const
;
114
119
const
NodeProperty< Size >
&
modalities
()
const
;
120
122
123
private
:
125
void
_buildGraph_
(
const
PRM< GUM_SCALAR >
&
prm
);
126
128
void
_addNode_
(
const
PRMClassElementContainer< GUM_SCALAR >
* c,
129
const
PRMClassElement< GUM_SCALAR >
& elt);
130
132
void
_addArcs_
(
const
PRMClassElementContainer< GUM_SCALAR >
& c,
133
NodeId
node,
134
HashTable
<
const
PRMClassElement< GUM_SCALAR >
*,
NodeId
>& map);
135
137
DAG
_graph_
;
138
144
NodeProperty< Size >
_modalitites_
;
145
151
NodeProperty< EltPair* >
_elt_map_
;
152
154
using
NodeMap
=
HashTable< const PRMClassElementContainer< GUM_SCALAR >
*,
155
HashTable< const PRMClassElement< GUM_SCALAR >
*,
NodeId
>* >;
156
160
NodeMap
_node_map_
;
161
};
162
163
164
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
165
extern
template
class
ClassDependencyGraph< double >
;
166
#endif
167
168
}
/* namespace prm */
169
}
/* namespace gum */
170
171
#include <
agrum/PRM/classDependencyGraph_tpl.h
>
172
173
#endif
/* GUM_CLASS_DEPENDENCY_GRAPH_H */
PRM.h
Headers of PRM.
classDependencyGraph_tpl.h
Inline implementation of ClassDependencyGraph.
gum::DAG
Base class for dag.
Definition
DAG.h:121
gum::HashTable
The class for generic Hash Tables.
Definition
hashTable.h:640
gum::prm::ClassDependencyGraph
This class represent the dependencies of all classes in a PRM<GUM_SCALAR>.
Definition
classDependencyGraph.h:66
gum::prm::ClassDependencyGraph::ClassDependencyGraph
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.
Definition
classDependencyGraph_tpl.h:124
gum::prm::ClassDependencyGraph::_elt_map_
NodeProperty< EltPair * > _elt_map_
Mapping between the nodes in graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
Definition
classDependencyGraph.h:151
gum::prm::ClassDependencyGraph::modalities
const NodeProperty< Size > & modalities() const
Returns a mapping between the ClassDependencyGraph<GUM_SCALAR>'s nodes and their modalities.
Definition
classDependencyGraph_tpl.h:160
gum::prm::ClassDependencyGraph::_addNode_
void _addNode_(const PRMClassElementContainer< GUM_SCALAR > *c, const PRMClassElement< GUM_SCALAR > &elt)
Add nodes in graph while updating consequently all the mappings.
Definition
classDependencyGraph_tpl.h:165
gum::prm::ClassDependencyGraph::_modalitites_
NodeProperty< Size > _modalitites_
The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a...
Definition
classDependencyGraph.h:144
gum::prm::ClassDependencyGraph::_buildGraph_
void _buildGraph_(const PRM< GUM_SCALAR > &prm)
Build the class dependency graph.
Definition
classDependencyGraph_tpl.h:69
gum::prm::ClassDependencyGraph::_graph_
DAG _graph_
The graph itself.
Definition
classDependencyGraph.h:137
gum::prm::ClassDependencyGraph::_addArcs_
void _addArcs_(const PRMClassElementContainer< GUM_SCALAR > &c, NodeId node, HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > &map)
Add arcs in graph.
Definition
classDependencyGraph_tpl.h:94
gum::prm::ClassDependencyGraph::get
const EltPair & get(NodeId id) const
Returns a constant reference over the element assiociated with the node id in the ClassDependencyGrap...
Definition
classDependencyGraph_tpl.h:149
gum::prm::ClassDependencyGraph::_node_map_
NodeMap _node_map_
Map each Class to a HashTable mapping the Class's ClassElements to their assigned NodeId in graph.
Definition
classDependencyGraph.h:160
gum::prm::ClassDependencyGraph::NodeMap
HashTable< const PRMClassElementContainer< GUM_SCALAR > *, HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > * > NodeMap
Code shortcut.
Definition
classDependencyGraph.h:154
gum::prm::ClassDependencyGraph::EltPair
std::pair< const PRMClassElementContainer< GUM_SCALAR > *, const PRMClassElement< GUM_SCALAR > * > EltPair
Association between a class element and it's holding class.
Definition
classDependencyGraph.h:69
gum::prm::ClassDependencyGraph::internalDag
const DAG & internalDag() const
Returns a constant reference over the graph of the DAG representing the ClassDependencyGraph<GUM_SCAL...
Definition
classDependencyGraph_tpl.h:143
gum::prm::PRMClassElementContainer
<agrum/PRM/classElementContainer.h>
Definition
PRMClassElementContainer.h:79
gum::prm::PRMClassElement
Abstract class representing an element of PRM class.
Definition
PRMClassElement.h:75
gum::prm::PRM
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition
PRM.h:74
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
gum::NodeProperty
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Definition
graphElements.h:407
gum::prm
namespace for all probabilistic relational models entities
Definition
agrum.h:68
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0