aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
DAG.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
52
53#ifdef GUM_NO_INLINE
55#endif // GU%_NO_INLINE
56
57namespace gum {
58
59 // diamond structure require to explicitly initialize NodeGraphPart
60 DAG::DAG(Size nodes_size, bool nodes_resize_policy, Size arcs_size, bool arcs_resize_policy) :
61 NodeGraphPart(nodes_size, nodes_resize_policy),
62 DiGraph(nodes_size, nodes_resize_policy, arcs_size, arcs_resize_policy) {
63 GUM_CONSTRUCTOR(DAG);
64 }
65
66 // diamond structure require to explicitly initialize NodeGraphPart
67 DAG::DAG(const DAG& g) : NodeGraphPart(g), DiGraph(g) { GUM_CONS_CPY(DAG); }
68
69 // diamond structure require to explicitly initialize NodeGraphPart
70 DAG::DAG(DAG&& g) : NodeGraphPart(std::move(g)), DiGraph(std::move(g)) { GUM_CONS_MOV(DAG); }
71
72 DAG::~DAG() { GUM_DESTRUCTOR(DAG); }
73
74 UndiGraph DAG::moralGraph() const { return graph::moralGraph(*this); }
75
79
80 bool DAG::dSeparation(NodeId X, NodeId Y, const NodeSet& Z) const {
81 return graph::dSeparated(*this, X, Y, Z);
82 }
83
84 bool DAG::dSeparation(const NodeSet& X, const NodeSet& Y, const NodeSet& Z) const {
85 return graph::dSeparated(*this, X, Y, Z);
86 }
87
88 NodeSet DAG::minimalCondSet(NodeId target, const NodeSet& soids) const {
89 return graph::minimalCondSet(*this, target, soids);
90 }
91
92 NodeSet DAG::minimalCondSet(const NodeSet& targets, const NodeSet& soids) const {
93 return graph::minimalCondSet(*this, targets, soids);
94 }
95} /* namespace gum */
Base classes for directed acyclic graphs.
Inline implementation of Base classes for directed acylic graphs.
d-Separation and c-Separation tests for aGrUM graphs.
bool dSeparation(NodeId X, NodeId Y, const NodeSet &Z) const
check if node X and node Y are independent given nodes Z (in the sense of d-separation)
Definition DAG.cpp:80
UndiGraph moralGraph() const
build a UndiGraph by moralizing the dag
Definition DAG.cpp:74
NodeSet minimalCondSet(NodeId target, const NodeSet &soids) const
Definition DAG.cpp:88
DAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition DAG.cpp:60
~DAG() override
destructor
Definition DAG.cpp:72
UndiGraph moralizedAncestralGraph(const NodeSet &nodes) const
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
Definition DAG.cpp:76
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition diGraph.cpp:70
Class for node sets in graph.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
Base class for undirected graphs.
Definition undiGraph.h:130
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Generic minimal conditioning set algorithm for directed graphs.
Moralization algorithms for aGrUM directed and mixed graphs.
UndiGraph moralizedAncestralGraph(const G &g, const NodeSet &query)
Returns the moralized ancestral graph of query in g.
bool dSeparated(const G &g, NodeId X, NodeId Y, const NodeSet &Z)
Returns true iff X and Y are d-separated by Z in g.
UndiGraph moralGraph(const G &g)
Returns the moral graph of g.
NodeSet minimalCondSet(const G &g, NodeId target, const NodeSet &soids)
Returns the minimal subset of soids that d-connects target.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.