aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
mixedGraph.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
47#ifndef GUM_MIXED_GRAPH_H
48#define GUM_MIXED_GRAPH_H
49
50#include <iostream>
51#include <utility>
52
53#include <agrum/agrum.h>
54
57
58namespace gum {
59
60 /* ===========================================================================
61 */
62 /* === BASE CLASS FOR MANIPULATING GRAPHS WITH BOTH EDGES AND ARCS ===
63 */
64 /* ===========================================================================
65 */
143 /* ===========================================================================
144 */
145
146 class MixedGraph: public UndiGraph, public DiGraph {
147 public:
148 // ############################################################################
150 // ############################################################################
152
154
160 explicit MixedGraph(Size nodes_size = HashTableConst::default_size,
161 bool nodes_resize_policy = true,
163 bool arcs_resize_policy = true,
165 bool edges_resize_policy = true);
166
167 explicit MixedGraph(const UndiGraph& g);
168
169 explicit MixedGraph(const DiGraph& g);
170
172
173 MixedGraph(const MixedGraph& g);
174
176 virtual ~MixedGraph();
177
179
180 // ############################################################################
182 // ############################################################################
184
186
188
189
191
192 // not virtual : it is a feature !!! :)
193 bool operator==(const MixedGraph& g) const;
194
196
197 // ############################################################################
199 // ############################################################################
201
203
206 void eraseNode(const NodeId node) override;
207
209 void clear() override;
210
219 std::vector< NodeId > mixedOrientedPath(NodeId node1, NodeId node2) const;
220
227 bool hasMixedOrientedPath(NodeId node1, NodeId node2) const;
228
230
235 std::vector< NodeId > mixedUnorientedPath(NodeId node1, NodeId node2) const;
236
238 std::string toDot() const override;
239
241 std::string toString() const override;
242
244
246 NodeSet boundary(NodeId node) const;
247
249
251 NodeSet chainComponent(NodeId node) const;
253 };
254
256 std::ostream& operator<<(std::ostream&, const MixedGraph&);
257
258} /* namespace gum */
259
260#ifndef GUM_NO_INLINE
262#endif // GU%_NO_INLINE
263
264#endif /* GUM_MIXEDGRAPH_H */
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:69
Base class for mixed graphs.
Definition mixedGraph.h:146
NodeSet chainComponent(NodeId node) const
returns the set of nodes reachable by undirected path
std::string toString() const override
to friendly display the content of the MixedGraph
void eraseNode(const NodeId node) override
remove a node as well as its adjacent arcs and edges from the graph
std::string toDot() const override
to friendly display mixed graph in DOT format
MixedGraph & operator=(const MixedGraph &g)
copy operator
std::vector< NodeId > mixedUnorientedPath(NodeId node1, NodeId node2) const
returns a mixed/directed path from node1 to node2 in the arc/edge set
NodeSet boundary(NodeId node) const
returns the set of node adjacent to a given node
void clear() override
removes all the nodes, arcs and edges from the graph
MixedGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
bool operator==(const MixedGraph &g) const
tests whether two MixedGraphs are identical (same nodes, arcs and edges)
bool hasMixedOrientedPath(NodeId node1, NodeId node2) const
returns true if a mixed edge/directed arc path from node1 to node2 in the arc/edge set exists.
virtual ~MixedGraph()
destructor
std::vector< NodeId > mixedOrientedPath(NodeId node1, NodeId node2) const
returns a mixed edge/directed arc path from node1 to node2 in the arc/edge set
UndiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
Definition undiGraph.cpp:72
Base classes for oriented graphs.
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 ...
Inline implementation of Base classes for mixed graphs.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Definition AVLTree.h:913
static constexpr Size default_size
The default number of slots in hashtables.
Definition hashTable.h:101
Base classes for undirected graphs.