aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
UGmodel.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
49#ifndef GUM_UGMODEL_H
50#define GUM_UGMODEL_H
51
52#include <agrum/agrum.h>
53
55
56namespace gum {
57
65 public:
68
72 UGmodel();
73
77 ~UGmodel() override;
78
82 UGmodel(const UGmodel& source);
83
85 UGmodel(UGmodel&& source);
86
90
94
99 [[nodiscard]] UndiGraph graph() const;
100
104 Size size() const final;
105
109 Size sizeEdges() const;
110
111 const NodeGraphPart& nodes() const final;
112
116 bool exists(NodeId node) const final;
117 bool exists(std::string_view name) const final;
118
120
123 const EdgeSet& edges() const;
124
126
132 bool existsEdge(const NodeId node1, const NodeId node2) const;
133 bool existsEdge(std::string_view name1, std::string_view name2) const;
134
136
139 const NodeSet& neighbours(const NodeId id) const;
140 const NodeSet& neighbours(std::string_view name) const;
141
144 bool isIndependent(NodeId X, NodeId Y, const NodeSet& Z) const final;
147 bool isIndependent(const NodeSet& X, const NodeSet& Y, const NodeSet& Z) const final;
148
149 bool isIndependent(std::string_view Xname,
150 std::string_view Yname,
151 const std::vector< std::string >& Znames) const;
152
153 bool isIndependent(const std::vector< std::string >& Xnames,
154 const std::vector< std::string >& Ynames,
155 const std::vector< std::string >& Znames) const;
156
159 // virtual bool isIndependent(const NodeSet& X, const NodeSet& Y, const
160 // NodeSet& Z) const;
161
163
166 bool hasSameStructure(const UGmodel& other) const;
167
171
173
177 NodeSet family(const NodeId id) const final;
178 NodeSet family(std::string_view name) const final;
179
183 const UndiGraph& internalGraph() const;
184
185 protected:
189 UGmodel& operator=(const UGmodel& source);
190
192 UGmodel& operator=(UGmodel&& source);
193
196 };
197} // namespace gum
198
199#ifndef GUM_NO_INLINE
201#endif /* GUM_NO_INLINE */
202
203#endif /* GUM_UGMODEL_H */
Interface-like class encapsulating basic functionalities for a IMarkovRandomFieldwork.
Class for node sets in graph.
bool hasSameStructure(const UGmodel &other) const
check if nodes X and nodes Y are independent given nodes Z
Definition UGmodel.cpp:82
UGmodel()
Default constructor.
Definition UGmodel.cpp:49
NodeSet family(const NodeId id) const final
returns the node as a NodeSet (in mixed graph : family is the node and its parents
const NodeGraphPart & nodes() const final
Returns a named copy of the internal undirected graph: each node id is assigned the name of the corre...
Definition UGmodel_inl.h:97
UGmodel & operator=(const UGmodel &source)
Private copy operator.
Definition UGmodel.cpp:62
bool existsEdge(const NodeId node1, const NodeId node2) const
return true if the edge node1-node2 exists in the UGModel
Definition UGmodel_inl.h:75
const UndiGraph & internalGraph() const
Returns a const reference to the internal (unnamed) graph. O(1), no copy. Use for stable references o...
Definition UGmodel_inl.h:58
bool exists(NodeId node) const final
Return true if this node exists in this graphical model.
Definition UGmodel_inl.h:89
UndiGraph graph_
The DAG of this Directed Graphical Model.
Definition UGmodel.h:195
const EdgeSet & edges() const
return true if the edge node1-node2 exists in the UGModel
Definition UGmodel_inl.h:73
~UGmodel() override
Destructor.
Definition UGmodel.cpp:60
UndiGraph graph() const
Returns a named copy of the internal undirected graph: each node id is assigned the name of the corre...
Definition UGmodel_inl.h:61
bool isIndependent(NodeId X, NodeId Y, const NodeSet &Z) const final
check if X and Y are independent given Z
const NodeSet & neighbours(const NodeId id) const
returns the neighbours of a node as set of nodes
Definition UGmodel_inl.h:83
NodeProperty< NodeId > connectedComponents() const
Returns the connected components of the underlying undirected graph. Each node maps to the id of its ...
Size sizeEdges() const
Returns the number of arcs in this Directed Graphical Model.
Definition UGmodel_inl.h:71
Size size() const final
Returns the number of variables in this Directed Graphical Model.
Definition UGmodel_inl.h:68
Base class for undirected graphs.
Definition undiGraph.h:130
Base class for graphical models over discrete variables.
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.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
Definition agrum.h:46