aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
edgeGrowth_tpl.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
#pragma once
42
43
50
51
#include <
agrum/PRM/gspan/edgeGrowth.h
>
52
53
namespace
gum
{
54
namespace
prm
{
55
namespace
gspan
{
56
57
template
< GUM_Numeric GUM_SCALAR >
58
EdgeGrowth< GUM_SCALAR >::EdgeGrowth
(
NodeId
a_u,
59
LabelData
* an_edge,
60
LabelData
* a_l_v,
61
NodeId
a_v) :
62
u
(a_u),
edge
(an_edge),
l_v
(a_l_v),
v
(a_v),
degree_list
(new
std
::vector<
NodeId
>()) {
63
GUM_CONSTRUCTOR(
EdgeGrowth
);
64
}
65
66
template
< GUM_Numeric GUM_SCALAR >
67
EdgeGrowth< GUM_SCALAR >::EdgeGrowth
(
const
EdgeGrowth< GUM_SCALAR >
& from) :
68
u
(from.
u
),
edge
(from.
edge
),
v
(from.
v
),
matches
(from.
matches
),
iso_graph
(from.
iso_graph
),
69
degree_list
(0),
max_indep_set
(from.
max_indep_set
) {
70
GUM_CONS_CPY(
EdgeGrowth
);
71
72
if
(from.
degree_list
!= 0) {
degree_list
=
new
std::vector< NodeId >(*(from.
degree_list
)); }
73
}
74
75
template
< GUM_Numeric GUM_SCALAR >
76
EdgeGrowth< GUM_SCALAR >::~EdgeGrowth
() {
77
GUM_DESTRUCTOR(
EdgeGrowth
);
78
79
if
(
degree_list
!= 0) {
delete
degree_list
; }
80
}
81
82
template
< GUM_Numeric GUM_SCALAR >
83
std::string
EdgeGrowth< GUM_SCALAR >::toString
() {
84
std::stringstream str;
85
str <<
u
<<
"-"
<<
edge
<<
"-"
<<
l_v
<<
"-"
<<
v
;
86
return
str.str();
87
}
88
89
template
< GUM_Numeric GUM_SCALAR >
90
void
EdgeGrowth< GUM_SCALAR >::insert
(
PRMInstance< GUM_SCALAR >
*
u
,
91
PRMInstance< GUM_SCALAR >
*
v
) {
92
NodeId
id
=
iso_graph
.addNode();
93
degree_list
->push_back(
id
);
94
95
for
(
const
auto
& elt:
matches
) {
96
if
((elt.second.first ==
u
) || (elt.second.second ==
u
) || (elt.second.first ==
v
)
97
|| (elt.second.second ==
v
)) {
98
iso_graph
.addEdge(elt.first,
id
);
99
}
100
}
101
102
// The order between u and v is important ! DO NOT INVERSE IT !
103
matches
.insert(
id
, std::make_pair(
u
,
v
));
104
}
105
106
}
/* namespace gspan */
107
}
/* namespace prm */
108
}
/* namespace gum */
gum::prm::PRMInstance
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
Definition
PRMInstance.h:79
gum::prm::gspan::EdgeGrowth::u
NodeId u
The id of the node from which we grow an edge.
Definition
edgeGrowth.h:83
gum::prm::gspan::EdgeGrowth::degree_list
std::vector< NodeId > * degree_list
Vector used for computation.
Definition
edgeGrowth.h:103
gum::prm::gspan::EdgeGrowth::matches
NodeProperty< std::pair< PRMInstance< GUM_SCALAR > *, PRMInstance< GUM_SCALAR > * > > matches
The mapping between the u and v for each match in the interface graph.
Definition
edgeGrowth.h:95
gum::prm::gspan::EdgeGrowth::max_indep_set
Set< NodeId > max_indep_set
The max indep set of matches.
Definition
edgeGrowth.h:105
gum::prm::gspan::EdgeGrowth::v
NodeId v
If the growth is backward you must assigned the subscript of v, otherwise 0 is assigned (recall that ...
Definition
edgeGrowth.h:90
gum::prm::gspan::EdgeGrowth::iso_graph
UndiGraph iso_graph
The iso graph for computing the maximum independent set of matches.
Definition
edgeGrowth.h:101
gum::prm::gspan::EdgeGrowth::EdgeGrowth
EdgeGrowth(NodeId a_u, LabelData *an_edge, LabelData *a_l_v, NodeId a_v=0)
Constructor.
Definition
edgeGrowth_tpl.h:58
gum::prm::gspan::EdgeGrowth::edge
LabelData * edge
The LabelData over the edge of this edge growth.
Definition
edgeGrowth.h:85
gum::prm::gspan::EdgeGrowth::~EdgeGrowth
~EdgeGrowth()
Destructor.
Definition
edgeGrowth_tpl.h:76
gum::prm::gspan::EdgeGrowth::l_v
LabelData * l_v
The LabelData over the node of this edge growth.
Definition
edgeGrowth.h:87
gum::prm::gspan::EdgeGrowth::toString
std::string toString()
Return a string representation of this.
Definition
edgeGrowth_tpl.h:83
gum::prm::gspan::EdgeGrowth::insert
void insert(PRMInstance< GUM_SCALAR > *u, PRMInstance< GUM_SCALAR > *v)
Add the pair (u,v) as a match for the current growth.
Definition
edgeGrowth_tpl.h:90
edgeGrowth.h
Headers of the DFSTree class.
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
gum::prm::gspan
Definition
DFSCode.cpp:57
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
std
STL namespace.
gum::prm::gspan::LabelData
Inner class to handle data about labels in this interface graph.
Definition
interfaceGraph.h:68
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0