aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
essentialGraph.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Class building the essential Graph from a DAGmodel
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
27  *
28  */
29 #ifndef GUM_ESSENTIALGRAPH_H
30 #define GUM_ESSENTIALGRAPH_H
31 
32 #include <agrum/tools/graphicalModels/DAGmodel.h>
33 #include <agrum/tools/graphs/graphElements.h>
34 #include <agrum/tools/graphs/mixedGraph.h>
35 #include <agrum/tools/graphs/undiGraph.h>
36 
37 namespace gum {
38 
39  /**
40  * @class EssentialGraph
41  * @headerfile essentialGraph.h <agrum/BN/algorithms/essentialGraph.h>
42  * @brief Class building the essential graph from a BN.
43  * @ingroup bn_group
44  *
45  * Essential graph is a mixed graph (Chain Graph) that represents the class of
46  * markov equivalent Bayesian networks (with the same independence model).
47  *
48  * The main goal of this class is to nest the algorithm to build the essential
49  * graph from a BN and to encapsulate the representation (as a MixedGraph) of the
50  * essential graph.
51  *
52  * gum::operator<<(std::ostream&, const BayesNet<GUM_SCALAR>&).
53  */
55  public:
56  EssentialGraph() = default;
57  // this constructor will build the essential graph
58  explicit EssentialGraph(const DAGmodel& m);
59  // this constructor will use mh as essential graph for m
60  EssentialGraph(const DAGmodel& m, const MixedGraph& mg);
63 
64  ~EssentialGraph();
65 
66  /// @return a copy of the mixed graph
68 
69  /// @return a dot representation of this essentialGraph
70  std::string toDot() const;
71 
72  /// wrapping @ref MixedGraph::parents(id)
73  const NodeSet& parents(NodeId id) const;
74 
75  /// wrapping @ref MixedGraph::parents(id)
76  const NodeSet& children(NodeId id) const;
77 
78  /// wrapping @ref MixedGraph::parents(ids)
79  NodeSet parents(const NodeSet& ids) const;
80 
81  /// wrapping @ref MixedGraph::parents(ids)
82  NodeSet children(const NodeSet& ids) const;
83 
84  /// wrapping @ref MixedGraph::parents(id)
85  const NodeSet& neighbours(NodeId id) const;
86 
87  /// wrapping @ref MixedGraph::sizeArcs()
88  Size sizeArcs() const;
89 
90  /// wrapping @ref MixedGraph::arcs()
91  const ArcSet& arcs() const;
92  /// wrapping @ref MixedGraph::sizeEdges()
93  Size sizeEdges() const;
94 
95  /// wrapping @ref MixedGraph::edges()
96  const EdgeSet& edges() const;
97 
98  /// wrapping @ref MixedGraph::sizeNodes()
99  Size sizeNodes() const;
100  /// wrapping @ref MixedGraph::size()
101  Size size() const;
102 
103  UndiGraph skeleton() const;
104 
105  /// wrapping @ref MixedGraph::nodes()
106  const NodeGraphPart& nodes() const;
107 
108  private:
109  void _buildEssentialGraph_();
110  bool _strongly_protected_(NodeId a, NodeId b);
111 
114  };
115 } // namespace gum
116 
117 #ifndef GUM_NO_INLINE
118 # include <agrum/BN/algorithms/essentialGraph_inl.h>
119 #endif // GUM_NOINLINE
120 
121 #endif // GUM_ESSENTIALGRAPH_H
NodeSet parents(const NodeSet &ids) const
wrapping MixedGraph::parents(ids)
const NodeGraphPart & nodes() const
wrapping MixedGraph::nodes()
const NodeSet & parents(NodeId id) const
wrapping MixedGraph::parents(id)
EssentialGraph & operator=(const EssentialGraph &g)
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
NodeSet children(const NodeSet &ids) const
wrapping MixedGraph::parents(ids)
std::string toDot() const
Size size() const
wrapping MixedGraph::size()
UndiGraph skeleton() const
const NodeSet & neighbours(NodeId id) const
wrapping MixedGraph::parents(id)
Size sizeEdges() const
wrapping MixedGraph::sizeEdges()
Size sizeArcs() const
wrapping MixedGraph::sizeArcs()
Size sizeNodes() const
wrapping MixedGraph::sizeNodes()
const EdgeSet & edges() const
wrapping MixedGraph::edges()
const NodeSet & children(NodeId id) const
wrapping MixedGraph::parents(id)
EssentialGraph(const DAGmodel &m, const MixedGraph &mg)
EssentialGraph(const DAGmodel &m)
Class building the essential graph from a BN.
EssentialGraph(const EssentialGraph &g)
bool _strongly_protected_(NodeId a, NodeId b)
const DAGmodel * _dagmodel_
EssentialGraph()=default
const ArcSet & arcs() const
wrapping MixedGraph::arcs()