aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
MeekRules.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
47
48#ifndef GUM_MEEKRULES_H
49#define GUM_MEEKRULES_H
50
52
53namespace gum {
67 class MeekRules {
68 public:
69 // ############################################################################
71 // ############################################################################
73
75 MeekRules();
76
78 virtual ~MeekRules();
79
81
83
91
93
100
102
107 DAG propagateToDAG(const MixedGraph& mg);
108
110
115 const std::vector< Arc >& choices() const;
116
117 private:
120
121 std::vector< Arc > _choices_;
122
124
129
131
136
138
142 static void _orientDoubleHeadedArcs_(MixedGraph& mg);
143
145
149 [[nodiscard]] static bool _isOrientable_(const MixedGraph& graph, NodeId xi, NodeId xj);
150
152 static bool _existsDirectedPath_(const MixedGraph& graph, NodeId n1, NodeId n2);
153
156
158
166 };
167
168} // namespace gum
169
170
171#ifndef GUM_NO_INLINE
173#endif // GUM_NO_INLINE
174
175#endif // GUM_MEEKRULES_H
Inline implementations of MeekRules.
Base classes for partially directed acyclic graphs.
The base class for all directed edges.
Base class for dag.
Definition DAG.h:121
MixedGraph _propagates_(const MixedGraph &graph)
Applies Meek rules R1–R4 exhaustively and returns the resulting graph.
PDAG propagateToCPDAG(const MixedGraph &mg)
Applies Meek rules and returns a CPDAG (completed PDAG).
Definition MeekRules.cpp:70
static bool _isOrientable_(const MixedGraph &graph, NodeId xi, NodeId xj)
Returns true if the edge xi–xj can be oriented as xi→xj under Meek rules R1–R3.
MixedGraph propagate(const MixedGraph &mg)
Applies Meek rules to a MixedGraph and returns the partially oriented result.
Definition MeekRules.cpp:64
std::vector< Arc > _choices_
Definition MeekRules.h:121
static bool _existsDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
Returns true if there is a directed path from n1 to n2 (BFS, double arcs ignored).
bool _applyMeekRules_(MixedGraph &graph, NodeId xj)
Tries to orient edges incident to xj using Meek rules R1–R4.
static Arc _selectArcToEraseByMinParents_(const MixedGraph &graph, NodeId x, NodeId y)
Returns the arc to erase when resolving a double-headed arc, using a min-parents heuristic.
virtual ~MeekRules()
destructor
Definition MeekRules.cpp:61
void _complete_(MixedGraph &graph)
Orients all remaining undirected edges, applying Meek rules then a chain heuristic.
static void _orientDoubleHeadedArcs_(MixedGraph &mg)
Resolves double-headed arcs (x→y and y→x simultaneously) to avoid cycles.
DAG propagateToDAG(const MixedGraph &mg)
Applies Meek rules and completes the result into a DAG.
Definition MeekRules.cpp:93
const std::vector< Arc > & choices() const
Returns the arcs for which the algorithm made an arbitrary orientation choice.
void _propagatesOrientationInChainOfRemainingEdges_(MixedGraph &graph)
Arbitrarily orients remaining undirected edges when no Meek rule applies.
MeekRules()
default constructor
Definition MeekRules.cpp:58
Base class for mixed graphs.
Definition mixedGraph.h:146
Base class for partially directed acyclic graphs.
Definition PDAG.h:130
Size NodeId
Type for node ids.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46