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