aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
graphChange_inl.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
52#include <agrum/BN/learning/structureUtils/graphChange.h> // to ease IDE parser
53#ifndef DOXYGEN_SHOULD_SKIP_THIS
54
55namespace gum {
56
57 namespace learning {
58
61 NodeId node1,
62 NodeId node2,
63 NodeId node3) noexcept : type_{type} {
64 nodes_[0] = LearnNodeId(node1);
65 nodes_[1] = LearnNodeId(node2);
66 nodes_[2] = LearnNodeId(node3);
67 GUM_CONSTRUCTOR(GraphChange);
68 }
69
71 INLINE GraphChange::GraphChange(const GraphChange& from) noexcept {
72 // Here, we know that nodes_ and type_ are of the same type, which
73 // is 32bit long (and aligned accordingly). In addition, type_ is
74 // defined just after nodes_ in Class GraphChange. Hence, memcpying 4
75 // elements starting from pointer nodes_ will copy both the 3 elements
76 // of nodes_ and type_
77 std::memcpy(nodes_, from.nodes_, 4 * sizeof(LearnNodeId));
78 GUM_CONS_CPY(GraphChange);
79 }
80
82 INLINE GraphChange::GraphChange(GraphChange&& from) noexcept {
83 // Here, we know that nodes_ and type_ are of the same type, which
84 // is 32bit long (and aligned accordingly). In addition, type_ is
85 // defined just after nodes_ in Class GraphChange. Hence, memcpying 4
86 // elements starting from pointer nodes_ will copy both the 3 elements
87 // of nodes_ and type_
88 std::memcpy(nodes_, from.nodes_, 4 * sizeof(LearnNodeId));
89 GUM_CONS_MOV(GraphChange);
90 }
91
93 INLINE GraphChange::~GraphChange() noexcept { GUM_DESTRUCTOR(GraphChange); }
94
96 INLINE GraphChange& GraphChange::operator=(const GraphChange& from) noexcept {
97 if (this != &from) {
98 // Here, we know that nodes_ and type_ are of the same type, which
99 // is 32bit long (and aligned accordingly). In addition, type_ is
100 // defined just after nodes_ in Class GraphChange. Hence, memcpying 4
101 // elements starting from pointer nodes_ will copy both the 3 elements
102 // of nodes_ and type_
103 std::memcpy(nodes_, from.nodes_, 4 * sizeof(LearnNodeId));
104 }
105 return *this;
106 }
107
109 INLINE GraphChange& GraphChange::operator=(GraphChange&& from) noexcept {
110 if (this != &from) {
111 // Here, we know that nodes_ and type_ are of the same type, which
112 // is 32bit long (and aligned accordingly). In addition, type_ is
113 // defined just after nodes_ in Class GraphChange. Hence, memcpying 4
114 // elements starting from pointer nodes_ will copy both the 3 elements
115 // of nodes_ and type_
116 std::memcpy(nodes_, from.nodes_, 4 * sizeof(LearnNodeId));
117 }
118 return *this;
119 }
120
122 INLINE GraphChangeType GraphChange::type() const noexcept { return type_; }
123
125 INLINE NodeId GraphChange::node1() const noexcept { return NodeId(nodes_[0]); }
126
128 INLINE NodeId GraphChange::node2() const noexcept { return NodeId(nodes_[1]); }
129
131 INLINE NodeId GraphChange::node3() const {
134 GUM_ERROR(InvalidNode, "GraphChange " << (int)(type_) << " does not involve a third node")
135 }
136 return NodeId(nodes_[2]);
137 }
138
140 INLINE bool GraphChange::operator==(const GraphChange& from) const noexcept {
141 // Here, we know that nodes_ and type_ are of the same type, which
142 // is 32bit long (and aligned accordingly). In addition, type_ is
143 // defined just after nodes_ in Class GraphChange. Hence, memcmping 4
144 // elements starting from pointer nodes_ will compare efficiently both
145 // the 3 elements of nodes_ and type_
146 return std::memcmp(nodes_, from.nodes_, 4 * sizeof(LearnNodeId)) == 0;
147 }
148
150 INLINE bool GraphChange::operator!=(const GraphChange& from) const noexcept {
151 return !operator==(from);
152 }
153
154 // ===========================================================================
155
157 INLINE ArcAddition::ArcAddition(NodeId node1, NodeId node2) noexcept :
159 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
160 // destructor, we did not make the latter's destructor virtual.
161 }
162
164 INLINE ArcAddition::ArcAddition(const ArcAddition& from) noexcept : GraphChange(from) {
165 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
166 // destructor, we did not make the latter's destructor virtual.
167 }
168
170 INLINE ArcAddition::ArcAddition(ArcAddition&& from) noexcept : GraphChange(std::move(from)) {
171 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
172 // destructor, we did not make the latter's destructor virtual.
173 }
174
176 INLINE ArcAddition::~ArcAddition() noexcept {
177 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
178 // destructor, we did not make the latter's destructor virtual.
179 }
180
182 INLINE ArcAddition& ArcAddition::operator=(const ArcAddition& from) noexcept = default;
183
185 INLINE ArcAddition& ArcAddition::operator=(ArcAddition&& from) noexcept {
186 GraphChange::operator=(std::move(from));
187 return *this;
188 }
189
191 INLINE bool ArcAddition::operator==(const ArcAddition& from) const noexcept {
192 // compare nodes_[0] and nodes_[1] in this and from
193 return std::memcmp(nodes_, from.nodes_, 2 * sizeof(LearnNodeId)) == 0;
194 }
195
197 INLINE bool ArcAddition::operator!=(const ArcAddition& from) const noexcept {
198 return !operator==(from);
199 }
200
201 // ===========================================================================
202
204 INLINE ArcDeletion::ArcDeletion(NodeId node1, NodeId node2) noexcept :
206 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
207 // destructor, we did not make the latter's destructor virtual.
208 }
209
211 INLINE ArcDeletion::ArcDeletion(const ArcDeletion& from) noexcept : GraphChange(from) {
212 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
213 // destructor, we did not make the latter's destructor virtual.
214 }
215
217 INLINE ArcDeletion::ArcDeletion(ArcDeletion&& from) noexcept : GraphChange(std::move(from)) {
218 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
219 // destructor, we did not make the latter's destructor virtual.
220 }
221
223 INLINE ArcDeletion::~ArcDeletion() noexcept {
224 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
225 // destructor, we did not make the latter's destructor virtual.
226 }
227
229 INLINE ArcDeletion& ArcDeletion::operator=(const ArcDeletion& from) noexcept = default;
230
232 INLINE ArcDeletion& ArcDeletion::operator=(ArcDeletion&& from) noexcept {
233 GraphChange::operator=(std::move(from));
234 return *this;
235 }
236
238 INLINE bool ArcDeletion::operator==(const ArcDeletion& from) const noexcept {
239 // compare nodes_[0] and nodes_[1] in this and from
240 return std::memcmp(nodes_, from.nodes_, 2 * sizeof(LearnNodeId)) == 0;
241 }
242
244 INLINE bool ArcDeletion::operator!=(const ArcDeletion& from) const noexcept {
245 return !operator==(from);
246 }
247
248 // ===========================================================================
249
251 INLINE ArcReversal::ArcReversal(NodeId node1, NodeId node2) noexcept :
253 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
254 // destructor, we did not make the latter's destructor virtual.
255 }
256
258 INLINE ArcReversal::ArcReversal(const ArcReversal& from) noexcept : GraphChange(from) {
259 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
260 // destructor, we did not make the latter's destructor virtual.
261 }
262
264 INLINE ArcReversal::ArcReversal(ArcReversal&& from) noexcept : GraphChange(std::move(from)) {
265 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
266 // destructor, we did not make the latter's destructor virtual.
267 }
268
270 INLINE ArcReversal::~ArcReversal() noexcept {
271 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
272 // destructor, we did not make the latter's destructor virtual.
273 }
274
276 INLINE ArcReversal& ArcReversal::operator=(const ArcReversal& from) noexcept = default;
277
279 INLINE ArcReversal& ArcReversal::operator=(ArcReversal&& from) noexcept {
280 GraphChange::operator=(std::move(from));
281 return *this;
282 }
283
285 INLINE bool ArcReversal::operator==(const ArcReversal& from) const noexcept {
286 // compare nodes_[0] and nodes_[1] in this and from
287 return std::memcmp(nodes_, from.nodes_, 2 * sizeof(LearnNodeId)) == 0;
288 }
289
291 INLINE bool ArcReversal::operator!=(const ArcReversal& from) const noexcept {
292 return !operator==(from);
293 }
294
295 // ===========================================================================
296
298 INLINE
299 ArcTriangleDeletion1::ArcTriangleDeletion1(NodeId node1, NodeId node2, NodeId node3) noexcept :
301 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
302 // destructor, we did not make the latter's destructor virtual.
303 }
304
307 GraphChange(from) {
308 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
309 // destructor, we did not make the latter's destructor virtual.
310 }
311
314 GraphChange(std::move(from)) {
315 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
316 // destructor, we did not make the latter's destructor virtual.
317 }
318
321 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
322 // destructor, we did not make the latter's destructor virtual.
323 }
324
327 ArcTriangleDeletion1::operator=(const ArcTriangleDeletion1& from) noexcept = default;
328
332 GraphChange::operator=(std::move(from));
333 return *this;
334 }
335
337 INLINE bool ArcTriangleDeletion1::operator==(const ArcTriangleDeletion1& from) const noexcept {
338 // compare nodes_[0], nodes_[1] and nodes_[2] in this and from
339 return std::memcmp(nodes_, from.nodes_, 3 * sizeof(LearnNodeId)) == 0;
340 }
341
343 INLINE bool ArcTriangleDeletion1::operator!=(const ArcTriangleDeletion1& from) const noexcept {
344 return !operator==(from);
345 }
346
348 INLINE NodeId ArcTriangleDeletion1::node3() const { return NodeId(nodes_[2]); }
349
350 // ===========================================================================
351
353 INLINE
354 ArcTriangleDeletion2::ArcTriangleDeletion2(NodeId node1, NodeId node2, NodeId node3) noexcept :
356 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
357 // destructor, we did not make the latter's destructor virtual.
358 }
359
362 GraphChange(from) {
363 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
364 // destructor, we did not make the latter's destructor virtual.
365 }
366
369 GraphChange(std::move(from)) {
370 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
371 // destructor, we did not make the latter's destructor virtual.
372 }
373
376 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
377 // destructor, we did not make the latter's destructor virtual.
378 }
379
382 ArcTriangleDeletion2::operator=(const ArcTriangleDeletion2& from) noexcept = default;
383
387 GraphChange::operator=(std::move(from));
388 return *this;
389 }
390
392 INLINE bool ArcTriangleDeletion2::operator==(const ArcTriangleDeletion2& from) const noexcept {
393 // compare nodes_[0], nodes_[1] and nodes_[2] in this and from
394 return std::memcmp(nodes_, from.nodes_, 3 * sizeof(LearnNodeId)) == 0;
395 }
396
398 INLINE bool ArcTriangleDeletion2::operator!=(const ArcTriangleDeletion2& from) const noexcept {
399 return !operator==(from);
400 }
401
403 INLINE NodeId ArcTriangleDeletion2::node3() const { return NodeId(nodes_[2]); }
404
405 // ===========================================================================
406
408 INLINE EdgeAddition::EdgeAddition(NodeId node1, NodeId node2) noexcept :
410 std::min(node1, node2),
411 std::max(node1, node2)) {
412 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
413 // destructor, we did not make the latter's destructor virtual.
414 }
415
417 INLINE EdgeAddition::EdgeAddition(const EdgeAddition& from) noexcept : GraphChange(from) {
418 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
419 // destructor, we did not make the latter's destructor virtual.
420 }
421
423 INLINE EdgeAddition::EdgeAddition(EdgeAddition&& from) noexcept : GraphChange(std::move(from)) {
424 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
425 // destructor, we did not make the latter's destructor virtual.
426 }
427
429 INLINE EdgeAddition::~EdgeAddition() noexcept {
430 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
431 // destructor, we did not make the latter's destructor virtual.
432 }
433
435 INLINE EdgeAddition& EdgeAddition::operator=(const EdgeAddition& from) noexcept = default;
436
438 INLINE EdgeAddition& EdgeAddition::operator=(EdgeAddition&& from) noexcept {
439 GraphChange::operator=(std::move(from));
440 return *this;
441 }
442
444 INLINE bool EdgeAddition::operator==(const EdgeAddition& from) const noexcept {
445 // compare nodes_[0] and nodes_[1] in this and from
446 return std::memcmp(nodes_, from.nodes_, 2 * sizeof(LearnNodeId)) == 0;
447 }
448
450 INLINE bool EdgeAddition::operator!=(const EdgeAddition& from) const noexcept {
451 return !operator==(from);
452 }
453
454 // ===========================================================================
455
457 INLINE EdgeDeletion::EdgeDeletion(NodeId node1, NodeId node2) noexcept :
459 std::min(node1, node2),
460 std::max(node1, node2)) {
461 // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
462 // destructor, we did not make the latter's destructor virtual.
463 }
464
466 INLINE EdgeDeletion::EdgeDeletion(const EdgeDeletion& from) noexcept : GraphChange(from) {
467 // do not use GUM_CONS_CPY here because, to speed up GraphChange's
468 // destructor, we did not make the latter's destructor virtual.
469 }
470
472 INLINE EdgeDeletion::EdgeDeletion(EdgeDeletion&& from) noexcept : GraphChange(std::move(from)) {
473 // do not use GUM_CONS_MOV here because, to speed up GraphChange's
474 // destructor, we did not make the latter's destructor virtual.
475 }
476
478 INLINE EdgeDeletion::~EdgeDeletion() noexcept {
479 // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
480 // destructor, we did not make the latter's destructor virtual.
481 }
482
484 INLINE EdgeDeletion& EdgeDeletion::operator=(const EdgeDeletion& from) noexcept = default;
485
487 INLINE EdgeDeletion& EdgeDeletion::operator=(EdgeDeletion&& from) noexcept {
488 GraphChange::operator=(std::move(from));
489 return *this;
490 }
491
493 INLINE bool EdgeDeletion::operator==(const EdgeDeletion& from) const noexcept {
494 // compare nodes_[0] and nodes_[1] in this and from
495 return std::memcmp(nodes_, from.nodes_, 2 * sizeof(LearnNodeId)) == 0;
496 }
497
499 INLINE bool EdgeDeletion::operator!=(const EdgeDeletion& from) const noexcept {
500 return !operator==(from);
501 }
502
503
504 } /* namespace learning */
505
506 // ===========================================================================
507
508 // Returns the value of a key as a Size.
510 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
511 // here, we assume that it is very unlikely that many triangles share the same
512 // arc. Hence, to avoid slowing down the computations of the mapping of
513 // ArcAddition, ArcDeletion and ArcReversal while not speeding-up much that
514 // of ArcTriangleDeletion1 and ArcTriangleDeletion2, we never take into account
515 // node3 in our computations.
516 return Size(key.type()) * HashFuncConst::gold + Size(key.node1()) * HashFuncConst::pi
517 + Size(key.node2()) * HashFuncConst::sqrt3;
518 } else {
519 // here we not only take into account the 3 nodes but also the type of
520 // the change
521 const Size* const nodes = (const Size*)key.nodes_;
522 return nodes[0] * HashFuncConst::gold + nodes[1] * HashFuncConst::pi;
523 }
524 }
525
526 // computes the hashed value of a key
527 INLINE Size
529 return castToSize(key) >> this->right_shift_;
530 }
531
532 // Returns the value of a key as a Size.
534 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
535 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
536 } else {
537 // here we take into account both node1() and node2()
538 const Size* const nodes = (Size*)key.nodes_;
539 return nodes[0] * HashFuncConst::gold;
540 }
541 }
542
543 // computes the hashed value of a key
544 INLINE Size
546 return castToSize(key) >> this->right_shift_;
547 }
548
549 // Returns the value of a key as a Size.
551 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
552 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
553 } else {
554 // here we take into account both node1() and node2()
555 const Size* const nodes = (Size*)key.nodes_;
556 return nodes[0] * HashFuncConst::gold;
557 }
558 }
559
560 // computes the hashed value of a key
561 INLINE Size
563 return castToSize(key) >> this->right_shift_;
564 }
565
566 // Returns the value of a key as a Size.
568 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
569 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
570 } else {
571 // here we take into account both node1() and node2()
572 const Size* const nodes = (Size*)key.nodes_;
573 return nodes[0] * HashFuncConst::gold;
574 }
575 }
576
577 // computes the hashed value of a key
578 INLINE Size
580 return castToSize(key) >> this->right_shift_;
581 }
582
583 // Returns the value of a key as a Size.
586 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
587 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi
588 + Size(key.node3()) * HashFuncConst::sqrt3;
589 } else {
590 // here we not only take into account the 3 nodes but also the type of
591 // the change
592 const Size* const nodes = (const Size*)key.nodes_;
593 return nodes[0] * HashFuncConst::gold + nodes[1] * HashFuncConst::pi;
594 }
595 }
596
597 // computes the hashed value of a key
599 const learning::ArcTriangleDeletion1& key) const {
600 return castToSize(key) >> this->right_shift_;
601 }
602
603 // Returns the value of a key as a Size.
606 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
607 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi
608 + Size(key.node3()) * HashFuncConst::sqrt3;
609 } else {
610 // here we not only take into account the 3 nodes but also the type of
611 // the change
612 const Size* const nodes = (const Size*)key.nodes_;
613 return nodes[0] * HashFuncConst::gold + nodes[1] * HashFuncConst::pi;
614 }
615 }
616
617 // computes the hashed value of a key
619 const learning::ArcTriangleDeletion2& key) const {
620 return castToSize(key) >> this->right_shift_;
621 }
622
623 // Returns the value of a key as a Size.
625 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
626 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
627 } else {
628 // here we take into account both node1() and node2()
629 const Size* const nodes = (Size*)key.nodes_;
630 return nodes[0] * HashFuncConst::gold;
631 }
632 }
633
635 INLINE Size
637 return castToSize(key) >> this->right_shift_;
638 }
639
640 // Returns the value of a key as a Size.
642 if constexpr (sizeof(learning::LearnNodeId) == sizeof(Size)) {
643 return Size(key.node1()) * HashFuncConst::gold + Size(key.node2()) * HashFuncConst::pi;
644 } else {
645 // here we take into account both node1() and node2()
646 const Size* const nodes = (Size*)key.nodes_;
647 return nodes[0] * HashFuncConst::gold;
648 }
649 }
650
652 INLINE Size
654 return castToSize(key) >> this->right_shift_;
655 }
656
657} /* namespace gum */
658
659#endif /* DOXYGEN_SHOULD_SKIP_THIS */
static Size castToSize(const learning::ArcAddition &key)
Returns the value of a key as a Size.
Size operator()(const learning::ArcAddition &key) const final
computes the hashed value of a key
Size operator()(const learning::ArcDeletion &key) const final
computes the hashed value of a key
static Size castToSize(const learning::ArcDeletion &key)
Returns the value of a key as a Size.
Size operator()(const learning::ArcReversal &key) const final
computes the hashed value of a key
static Size castToSize(const learning::ArcReversal &key)
Returns the value of a key as a Size.
static Size castToSize(const learning::ArcTriangleDeletion1 &key)
Returns the value of a key as a Size.
Size operator()(const learning::ArcTriangleDeletion1 &key) const final
computes the hashed value of a key
static Size castToSize(const learning::ArcTriangleDeletion2 &key)
Returns the value of a key as a Size.
Size operator()(const learning::ArcTriangleDeletion2 &key) const final
computes the hashed value of a key
Size operator()(const learning::EdgeAddition &key) const final
computes the hashed value of a key
static Size castToSize(const learning::EdgeAddition &key)
Returns the value of a key as a Size.
static Size castToSize(const learning::EdgeDeletion &key)
Returns the value of a key as a Size.
Size operator()(const learning::EdgeDeletion &key) const final
computes the hashed value of a key
static Size castToSize(const learning::GraphChange &key)
Returns the value of a key as a Size.
Size operator()(const learning::GraphChange &key) const final
computes the hashed value of a key
The class for notifying learning algorithms of new arc additions.
bool operator!=(const ArcAddition &from) const noexcept
returns whether two arc additions are different or not
ArcAddition & operator=(const ArcAddition &from) noexcept
copy constructor
ArcAddition(NodeId node1, NodeId node2) noexcept
default constructor
bool operator==(const ArcAddition &from) const noexcept
returns whether two arc additions are identical or not
~ArcAddition() noexcept
destructor
The class for notifying learning algorithms of arc removals.
bool operator!=(const ArcDeletion &from) const noexcept
returns whether two arc deletions are different or not
bool operator==(const ArcDeletion &from) const noexcept
returns whether two arc deletions are identical or not
ArcDeletion(NodeId node1, NodeId node2) noexcept
default constructor
ArcDeletion & operator=(const ArcDeletion &from) noexcept
copy constructor
~ArcDeletion() noexcept
destructor
The class for notifying learning algorithms of arc reversals.
ArcReversal & operator=(const ArcReversal &from) noexcept
copy constructor
bool operator!=(const ArcReversal &from) const noexcept
returns whether two arc reversals are different or not
ArcReversal(NodeId node1, NodeId node2) noexcept
default constructor
~ArcReversal() noexcept
destructor
bool operator==(const ArcReversal &from) const noexcept
returns whether two arc reversals are identical or not
The graph change substituting a triangle node1->node2->node3 + node1->node3 into v-structure node2->n...
ArcTriangleDeletion1(NodeId node1, NodeId node2, NodeId node3) noexcept
default constructor
ArcTriangleDeletion1 & operator=(const ArcTriangleDeletion1 &from) noexcept
copy constructor
NodeId node3() const
returns the third node involved in the modification (if any)
bool operator!=(const ArcTriangleDeletion1 &from) const noexcept
returns whether two ArcTriangleDeletion1 are different or not
bool operator==(const ArcTriangleDeletion1 &from) const noexcept
returns whether two ArcTriangleDeletion1 are identical or not
~ArcTriangleDeletion1() noexcept
destructor
The graph change substituting a triangle node1->node2->node3 + node1->node3 into v-structure node1->n...
bool operator==(const ArcTriangleDeletion2 &from) const noexcept
returns whether two ArcTriangleDeletion2 are identical or not
bool operator!=(const ArcTriangleDeletion2 &from) const noexcept
returns whether two ArcTriangleDeletion2 are different or not
ArcTriangleDeletion2 & operator=(const ArcTriangleDeletion2 &from) noexcept
copy constructor
~ArcTriangleDeletion2() noexcept
destructor
NodeId node3() const
returns the third node involved in the modification (if any)
ArcTriangleDeletion2(NodeId node1, NodeId node2, NodeId node3) noexcept
default constructor
The class for notifying learning algorithms of new edge additions.
bool operator!=(const EdgeAddition &from) const noexcept
returns whether two edge additions are different or not
bool operator==(const EdgeAddition &from) const noexcept
returns whether two edge additions are identical or not
EdgeAddition & operator=(const EdgeAddition &from) noexcept
copy constructor
EdgeAddition(NodeId node1, NodeId node2) noexcept
default constructor
~EdgeAddition() noexcept
destructor
The class for notifying learning algorithms of edge removals.
EdgeDeletion & operator=(const EdgeDeletion &from) noexcept
copy constructor
EdgeDeletion(NodeId node1, NodeId node2) noexcept
default constructor
~EdgeDeletion() noexcept
destructor
bool operator!=(const EdgeDeletion &from) const noexcept
returns whether two edge deletions are different or not
bool operator==(const EdgeDeletion &from) const noexcept
returns whether two edge deletions are identical or not
GraphChange(GraphChangeType type, NodeId node1, NodeId node2, NodeId node3=0) noexcept
default constructor
bool operator==(const GraphChange &from) const noexcept
returns whether two graph changes are identical or not
GraphChangeType type_
the type of modification
NodeId node1() const noexcept
returns the first node involved in the modification
GraphChangeType type() const noexcept
returns the type of the operation
GraphChange & operator=(const GraphChange &from) noexcept
copy constructor
LearnNodeId nodes_[3]
the nodes involved in the edge or arc to be modified
NodeId node2() const noexcept
returns the second node involved in the modification
NodeId node3() const
returns the third node involved in the modification (if any)
~GraphChange() noexcept
destructor
bool operator!=(const GraphChange &from) const noexcept
returns whether two graph changes are different or not
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
the classes to account for structure changes in a graph
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size NodeId
Type for node ids.
include the inlined functions if necessary
Definition CSVParser.h:55
GraphChangeType
the type of modification that can be applied to the graph
Definition graphChange.h:74
uint32_t LearnNodeId
the internal type of the nodes involved in the arc/edge modifications
Definition graphChange.h:71
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
bool operator==(const HashTableIteratorSafe< Key, Val > &from) const noexcept
Checks whether two iterators are pointing toward equal elements.
static constexpr Size sqrt3
Definition hashFunc.h:105
static constexpr Size pi
Definition hashFunc.h:103
static constexpr Size gold
Definition hashFunc.h:101