aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
reachability.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
56#ifndef GUM_GRAPH_REACHABILITY_H
57#define GUM_GRAPH_REACHABILITY_H
58
59#include <agrum/agrum.h>
60
62
63namespace gum::graph {
64
65 // =========================================================================
66 // Directed graphs (GUM_DiGraphable)
67 // =========================================================================
68
73 template < GUM_DiGraphable G >
74 NodeSet ancestors(const G& g, NodeId id);
75
80 template < GUM_DiGraphable G >
81 NodeSet descendants(const G& g, NodeId id);
82
84 template < GUM_DiGraphable G >
85 NodeSet family(const G& g, NodeId id);
86
88 template < GUM_DiGraphable G >
89 NodeSet family(const G& g, const NodeSet& ids);
90
91 // =========================================================================
92 // Undirected graphs (GUM_UndiGraphable)
93 // =========================================================================
94
102 template < GUM_UndiGraphable G >
104
115 template < GUM_NodeGraphable G >
117
132 template < GUM_UndiGraphable G >
133 bool areConnected(const G& g, const NodeSet& A, const NodeSet& B);
134
135 // =========================================================================
136 // Mixed graphs (GUM_MixedGraphable)
137 // =========================================================================
138
145 template < GUM_MixedGraphable G >
146 NodeSet chainComponent(const G& g, NodeId node);
147
149 template < GUM_MixedGraphable G >
150 NodeSet boundary(const G& g, NodeId node);
151
152} // namespace gum::graph
153
155
156#endif // GUM_GRAPH_REACHABILITY_H
C++20 concepts for aGrUM graph interfaces.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeSet descendants(const G &g, NodeId id)
Returns the set of all descendants of id (nodes reachable from id following arc direction).
NodeSet ancestors(const G &g, NodeId id)
Returns the set of all ancestors of id (nodes from which id is reachable following arc direction).
bool areConnected(const G &g, const NodeSet &A, const NodeSet &B)
Returns true iff some node in A can reach some node in B via undirected edges.
NodeSet boundary(const G &g, NodeId node)
Returns the boundary of node: neighbours ∪ parents ∪ children.
NodeProperty< NodeId > chainComponents(const G &g)
Returns a node-to-component-id mapping for the chain components of g (connected components of the edg...
NodeSet chainComponent(const G &g, NodeId node)
Returns the chain component of node in g.
NodeSet family(const G &g, NodeId id)
Returns the family of id : { id } ∪ parents(id).
NodeProperty< NodeId > connectedComponents(const G &g)
Returns a node-to-component-id mapping for the (weakly) connected components of g.
Template implementations for reachability.h.