aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
edgeGraphPart.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
42#ifndef GUM_EDGE_GRAPH_PART_H
43#define GUM_EDGE_GRAPH_PART_H
44
45
46#include <algorithm>
47#include <utility>
48
49#include <agrum/agrum.h>
50
53
54namespace gum {
55
93
95 public:
97
100
101 // ############################################################################
103 // ############################################################################
105
107
109 explicit EdgeGraphPart(Size edges_size = HashTableConst::default_size,
110 bool edges_resize_policy = true);
111
113
115
118
120 virtual ~EdgeGraphPart();
121
123
124 // ############################################################################
126 // ############################################################################
128
130
132
135
137
138 bool operator==(const EdgeGraphPart& p) const;
140
141 // ############################################################################
143 // ############################################################################
145
147
151 virtual void addEdge(NodeId n1, NodeId n2);
152
154
158 virtual void eraseEdge(const Edge& edge);
159
161
163 bool existsEdge(const Edge& edge) const;
164
166
170 bool existsEdge(NodeId n1, NodeId n2) const;
171
173 bool emptyEdges() const;
174
176 virtual void clearEdges();
177
179 Size sizeEdges() const;
180
182 const EdgeSet& edges() const;
183
185
188 const NodeSet& neighbours(NodeId id) const;
189
191
196 void eraseNeighbours(NodeId id);
197
200
202
204 virtual std::string toString() const;
205
214 template < typename VAL >
215 EdgeProperty< VAL > edgesProperty(VAL (*f)(const Edge&), Size size = 0) const;
216
225 template < typename VAL >
226 EdgeProperty< VAL > edgesProperty(const VAL& val, Size size = 0) const;
227
231 template < typename VAL >
232 List< VAL > listMapEdges(VAL (*f)(const Edge&)) const;
233
235
236 private:
239
242
246 void _checkNeighbours_(NodeId id);
247
248 void _clearEdges_();
249 };
250
252 std::ostream& operator<<(std::ostream&, const EdgeGraphPart&);
253
254} /* namespace gum */
255
256#ifndef GUM_NO_INLINE
258#endif // GUM_NO_INLINE
259
261
262#endif // GUM_EDGE_GRAPH_PART_H
Classes for undirected edge sets.
EdgeProperty< VAL > edgesProperty(VAL(*f)(const Edge &), Size size=0) const
a method to create a hashMap of VAL from a set of edges (using for every edge, say x,...
void unvirtualizedEraseNeighbours(NodeId id)
same function as eraseNeighbours but without any virtual call to an erase
Signaler< NodeId, NodeId > onEdgeAdded
Size sizeEdges() const
indicates the number of edges stored within the EdgeGraphPart
EdgeGraphPart & operator=(const EdgeGraphPart &s)
copy operator
virtual ~EdgeGraphPart()
destructor
void _checkNeighbours_(NodeId id)
when the EdgeGraphPart contains no edge adjacent to a given node, this function adds an empty set ent...
bool operator==(const EdgeGraphPart &p) const
tests whether two EdgeGraphParts contain the same edges
EdgeGraphPart(Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
virtual void addEdge(NodeId n1, NodeId n2)
insert a new edge into the EdgeGraphPart
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
EdgeSetIterator EdgeIterator
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
void eraseNeighbours(NodeId id)
erase all the edges adjacent to a given node
NodeProperty< NodeSet * > _neighbours_
for each node, the set of its adjacent edges
const EdgeSet & edges() const
returns the set of edges stored within the EdgeGraphPart
virtual std::string toString() const
to friendly display the content of the EdgeGraphPart
virtual void clearEdges()
removes all the edges from the EdgeGraphPart
Signaler< NodeId, NodeId > onEdgeDeleted
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
bool emptyEdges() const
indicates wether the EdgeGraphPart contains any edge
List< VAL > listMapEdges(VAL(*f)(const Edge &)) const
a method to create a list of VAL from a set of edges (using for every edge, say x,...
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
EdgeProperty< VAL > edgesProperty(const VAL &val, Size size=0) const
a method to create a hashMap of VAL from a set of edges (using for every edge, say x,...
The base class for all undirected edges.
Generic doubly linked lists.
Definition list.h:378
Inline implementation of classes for undirected edge sets.
Implementation of the EdgeGraphPart.
some utils for topology : NodeId, Edge, Arc and consorts ...
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< Edge, VAL > EdgeProperty
Property on graph elements.
EdgeSet::const_iterator EdgeSetIterator
Some typdefs and define for shortcuts ...
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
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Convenience header for the signal/listener pattern.
static constexpr Size default_size
The default number of slots in hashtables.
Definition hashTable.h:102