aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
graphChange.cpp
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
41
50
52
53#ifdef GUM_NO_INLINE
55#endif // GU%_NO_INLINE
56
57namespace gum {
58
59 namespace learning {
60
62 std::string GraphChange::toString() const {
63 std::stringstream stream;
64 switch (type()) {
66 stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
67 return stream.str();
68
70 stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
71 return stream.str();
72
74 stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
75 return stream.str();
76
78 stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
79 return stream.str();
80
82 stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
83 return stream.str();
84
85 default : GUM_ERROR(OperationNotAllowed, "this graph modification is not supported yet")
86 }
87 }
88
90 std::string ArcAddition::toString() const {
91 std::stringstream stream;
92 stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
93 return stream.str();
94 }
95
97 std::string ArcDeletion::toString() const {
98 std::stringstream stream;
99 stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
100 return stream.str();
101 }
102
104 std::string ArcReversal::toString() const {
105 std::stringstream stream;
106 stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
107 return stream.str();
108 }
109
111 std::string EdgeAddition::toString() const {
112 std::stringstream stream;
113 stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
114 return stream.str();
115 }
116
118 std::string EdgeDeletion::toString() const {
119 std::stringstream stream;
120 stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
121 return stream.str();
122 }
123
125 std::ostream& operator<<(std::ostream& stream, const GraphChange& change) {
126 return stream << change.toString();
127 }
128
130 std::ostream& operator<<(std::ostream& stream, const ArcAddition& change) {
131 return stream << change.toString();
132 }
133
135 std::ostream& operator<<(std::ostream& stream, const ArcDeletion& change) {
136 return stream << change.toString();
137 }
138
140 std::ostream& operator<<(std::ostream& stream, const ArcReversal& change) {
141 return stream << change.toString();
142 }
143
145 std::ostream& operator<<(std::ostream& stream, const EdgeAddition& change) {
146 return stream << change.toString();
147 }
148
150 std::ostream& operator<<(std::ostream& stream, const EdgeDeletion& change) {
151 return stream << change.toString();
152 }
153
154 } /* namespace learning */
155
156} /* namespace gum */
Exception : operation not allowed.
The class for notifying learning algorithms of new arc additions.
virtual std::string toString() const final
put the content of the ArcAddition into a string
The class for notifying learning algorithms of arc removals.
virtual std::string toString() const final
put the content of the ArcDeletion into a string
The class for notifying learning algorithms of arc reversals.
virtual std::string toString() const final
put the content of the ArcReversal into a string
The class for notifying learning algorithms of new edge additions.
virtual std::string toString() const final
put the content of the EdgeAddition into a string
The class for notifying learning algorithms of edge removals.
virtual std::string toString() const final
put the content of the EdgeDeletion into a string
NodeId node1() const noexcept
returns the first node involved in the modification
GraphChangeType type() const noexcept
returns the type of the operation
NodeId node2() const noexcept
returns the second node involved in the modification
virtual std::string toString() const
put the content of the graph change into a string
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
the classes to account for structure changes in a graph
A class to account for changes in a graph.
include the inlined functions if necessary
Definition CSVParser.h:54
std::ostream & operator<<(std::ostream &stream, const IdCondSet &idset)
the display operator
gum is the global namespace for all aGrUM entities
Definition agrum.h:46