aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
structuralConstraintTotalOrder.cpp
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
47
49
51#ifdef GUM_NO_INLINE
53#endif /* GUM_NO_INLINE */
54
55namespace gum {
56
57 namespace learning {
58
63
69
76
82
88
93
97 if (this != &from) { _total_order_ = from._total_order_; }
98 return *this;
99 }
100
104 if (this != &from) { _total_order_ = std::move(from._total_order_); }
105 return *this;
106 }
107
109 switch (change.type()) {
111 return !checkArcAdditionAlone(change.node1(), change.node2());
112
113 case GraphChangeType::ARC_DELETION : return false;
114
116 return !checkArcAdditionAlone(change.node2(), change.node1());
117
119 return !checkArcTriangleDeletion1Alone(change.node1(), change.node2(), change.node3());
120
122 return !checkArcTriangleDeletion2Alone(change.node1(), change.node2(), change.node3());
123
124 default :
126 "Graph change operation "
127 << change.typeAsString()
128 << " is not supported by the Total Order structural constraint");
129 }
130 }
131
133 switch (change.type()) {
135 return checkArcAdditionAlone(change.node1(), change.node2());
136
138 return checkArcDeletionAlone(change.node1(), change.node2());
139
141 return checkArcReversalAlone(change.node1(), change.node2());
142
144 return checkArcTriangleDeletion1Alone(change.node1(), change.node2(), change.node3());
145
147 return checkArcTriangleDeletion2Alone(change.node1(), change.node2(), change.node3());
148
149 default :
151 "edge modifications are not "
152 "supported by the Total Order structural constraint");
153 }
154 }
155 } /* namespace learning */
156
157} /* namespace gum */
Base class for all oriented graphs.
Definition diGraph.h:132
Exception : operation not allowed.
std::string typeAsString() const
returns a string corresponding to the type of the change
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
NodeId node3() const
returns the third node involved in the modification (if any)
the structural constraint imposing a total order over some nodes
Sequence< NodeId > _total_order_
the total ordering over the nodes
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
bool checkArcTriangleDeletion2Alone(NodeId node1, NodeId node2, NodeId node3) const
checks whether the constraints enable to apply an ArcTriangleDeletion2
bool checkModificationAlone(const ArcAddition &change) const
checks whether the constraints enable to add an arc
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
bool checkArcTriangleDeletion1Alone(NodeId node1, NodeId node2, NodeId node3) const
checks whether the constraints enable to apply an ArcTriangleDeletion1
StructuralConstraintTotalOrder & operator=(const StructuralConstraintTotalOrder &from)
copy operator
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
include the inlined functions if necessary
Definition CSVParser.h:55
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
the structural constraint imposing a total ordering over some nodes
the structural constraint imposing a total order over some nodes