aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
essentialGraph.h
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
49#ifndef GUM_ESSENTIALGRAPH_H
50#define GUM_ESSENTIALGRAPH_H
51
52#include <agrum/agrum.h>
53
56
57namespace gum {
58
75 public:
76 EssentialGraph() = default;
77 // this constructor will build the essential graph
78 explicit EssentialGraph(const DAGmodel& m);
79 // this constructor will use mh as essential graph for m
80 EssentialGraph(const DAGmodel& m, const PDAG& mg);
83
85
87 PDAG pdag() const;
88
90 std::string toDot() const;
91
93 const NodeSet& parents(NodeId id) const;
94
96 const NodeSet& children(NodeId id) const;
97
99 NodeSet parents(const NodeSet& ids) const;
100
102 NodeSet children(const NodeSet& ids) const;
103
105 const NodeSet& neighbours(NodeId id) const;
106
108 Size sizeArcs() const;
109
111 const ArcSet& arcs() const;
113 Size sizeEdges() const;
114
116 const EdgeSet& edges() const;
117
119 Size sizeNodes() const;
121 Size size() const;
122
123 UndiGraph skeleton() const;
124
126 const NodeGraphPart& nodes() const;
127
129 NodeId idFromName(const std::string& name) const;
130
132 const std::string& nameFromId(NodeId node) const;
133
134 private:
136 bool _strongly_protected_(NodeId a, NodeId b) const;
137
138 static bool _strongly_protected_(MixedGraph mg, NodeId a, NodeId b);
139
142 };
143} // namespace gum
144
145#ifndef GUM_NO_INLINE
147#endif // GU%_NO_INLINE
148
149#endif // GUM_ESSENTIALGRAPH_H
Class representing probabilistic DAG model.
Base classes for partially directed acyclic graphs.
Virtual base class for PGMs using a DAG.
Definition DAGmodel.h:64
const NodeSet & neighbours(NodeId id) const
wrapping MixedGraph::parents(id)
const std::string & nameFromId(NodeId node) const
wrappping .name()
Size sizeEdges() const
wrapping MixedGraph::sizeEdges()
NodeId idFromName(const std::string &name) const
wrappping DAGModel::idFromName()
const NodeSet & children(NodeId id) const
wrapping MixedGraph::parents(id)
Size sizeArcs() const
wrapping MixedGraph::sizeArcs()
const ArcSet & arcs() const
wrapping MixedGraph::arcs()
const DAGmodel * _dagmodel_
const NodeSet & parents(NodeId id) const
wrapping MixedGraph::parents(id)
UndiGraph skeleton() const
const NodeGraphPart & nodes() const
wrapping MixedGraph::nodes()
Size size() const
wrapping MixedGraph::size()
EssentialGraph & operator=(const EssentialGraph &g)
bool _strongly_protected_(NodeId a, NodeId b) const
EssentialGraph()=default
std::string toDot() const
const EdgeSet & edges() const
wrapping MixedGraph::edges()
Size sizeNodes() const
wrapping MixedGraph::sizeNodes()
Base class for mixed graphs.
Definition mixedGraph.h:146
Class for node sets in graph.
Base class for partially directed acyclic graphs.
Definition PDAG.h:130
Base class for undirected graphs.
Definition undiGraph.h:128
Inline implementation of the class building the essential Graph from a DAGmodel.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...
Size NodeId
Type for node ids.
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
Definition agrum.h:46