aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
mixedGraph_inl.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#pragma once
42
49
50// to ease parser in IDEs
54
55namespace gum {
56
58 // avoid self assignment
59 if (this != &g) {
60 // remove the old graph properly
64
65 // fill the new graph
69 GUM_OP_CPY(MixedGraph);
70 }
71
72 return *this;
73 }
74
76 if (this != &g) {
77 NodeGraphPart::operator=(std::move(g));
78 EdgeGraphPart::operator=(std::move(g));
79 ArcGraphPart::operator=(std::move(g));
80 GUM_OP_MOV(MixedGraph);
81 }
82 return *this;
83 }
84
90
97
102
103 INLINE NodeSet MixedGraph::boundary(NodeId node) const { return graph::boundary(*this, node); }
104
106 return graph::chainComponent(*this, node);
107 }
108
109 INLINE std::optional< std::vector< NodeId > > MixedGraph::mixedOrientedPath(NodeId n1,
110 NodeId n2) const {
111 return graph::mixedOrientedPath(*this, n1, n2);
112 }
113
115 return graph::hasMixedOrientedPath(*this, n1, n2);
116 }
117
118 INLINE std::optional< std::vector< NodeId > > MixedGraph::mixedUnorientedPath(NodeId n1,
119 NodeId n2) const {
120 return graph::mixedUnorientedPath(*this, n1, n2);
121 }
122
126
130
131} /* namespace gum */
bool operator==(const ArcGraphPart &p) const
tests whether two ArcGraphParts contain the same arcs
ArcGraphPart & operator=(const ArcGraphPart &s)
copy operator
void clearArcs()
removes all the arcs from the ArcGraphPart
void unvirtualizedEraseChildren(NodeId id)
same function as eraseChildren but without any virtual call to an erase
void unvirtualizedEraseParents(NodeId id)
same function as eraseParents but without any virtual call to an erase
void unvirtualizedEraseNeighbours(NodeId id)
same function as eraseNeighbours but without any virtual call to an erase
EdgeGraphPart & operator=(const EdgeGraphPart &s)
copy operator
bool operator==(const EdgeGraphPart &p) const
tests whether two EdgeGraphParts contain the same edges
virtual void clearEdges()
removes all the edges from the EdgeGraphPart
NodeProperty< NodeId > chainComponents() const
returns a property {node:id of chain component} (edges only)
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.
void eraseNode(const NodeId node) override
remove a node as well as its adjacent arcs and edges from the graph
MixedGraph & operator=(const MixedGraph &g)
copy operator
NodeSet chainComponent(NodeId node) const
returns the set of nodes reachable by undirected path
NodeSet boundary(NodeId node) const
returns the set of node adjacent to a given node
std::optional< 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
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)
NodeProperty< NodeId > connectedComponents() const
returns a property {node:id of weakly connected component}
std::optional< std::vector< NodeId > > mixedUnorientedPath(NodeId node1, NodeId node2) const
returns a mixed/directed path from node1 to node2 in the arc/edge set
virtual void eraseNode(const NodeId id)
erase the node with the given id
NodeGraphPart & operator=(const NodeGraphPart &p)
copy operator
virtual void clearNodes()
remove all the nodes from the NodeGraphPart
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Base classes for mixed directed/undirected graphs.
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...
bool hasMixedOrientedPath(const G &g, NodeId n1, NodeId n2)
Returns true if a mixed-oriented path from n1 to n2 exists.
NodeSet chainComponent(const G &g, NodeId node)
Returns the chain component of node in g.
std::optional< std::vector< NodeId > > mixedUnorientedPath(const G &g, NodeId n1, NodeId n2)
Shortest path ignoring all orientations in a mixed graph.
std::optional< std::vector< NodeId > > mixedOrientedPath(const G &g, NodeId n1, NodeId n2)
Shortest mixed-oriented path from n1 to n2.
NodeProperty< NodeId > connectedComponents(const G &g)
Returns a node-to-component-id mapping for the (weakly) connected components of g.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Generic BFS-based path-finding algorithms for aGrUM graphs.
Generic node-reachability algorithms for aGrUM graphs.