aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
edgeGraphPart_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief Inline implementation of classes for undirected edge sets
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
26  *
27  */
28 
29 // to ease parsing by IDE
30 #include <agrum/tools/graphs/parts/edgeGraphPart.h>
31 
32 namespace gum {
33 
34  INLINE bool EdgeGraphPart::emptyEdges() const { return _edges_.empty(); }
35 
36  INLINE Size EdgeGraphPart::sizeEdges() const { return _edges_.size(); }
37 
38  INLINE const EdgeSet& EdgeGraphPart::edges() const { return _edges_; }
39 
40  INLINE bool EdgeGraphPart::existsEdge(const Edge& edge) const { return _edges_.contains(edge); }
41 
42  INLINE bool EdgeGraphPart::existsEdge(const NodeId first, const NodeId second) const {
44  }
45 
48  }
49 
57 
59  }
60 
62  if (existsEdge(edge)) {
63  // ASSUMING first and second exists in _neighbours_ (if not, it is an
64  // error)
65  NodeId id1 = edge.first(), id2 = edge.second();
66 
71  }
72  }
73 
76  return *(_neighbours_[id]);
77  }
78 
80  if (_neighbours_.exists(id)) {
81  const NodeSet& set = neighbours(id);
82 
83  for (auto iter = set.beginSafe(); iter != set.endSafe();
84  ++iter) { // safe iterator needed here
85  // warning: use this erase so that you actually use the virtualized
86  // edge removal function
87  eraseEdge(Edge(*iter, id));
88  }
89  }
90  }
91 
93  if (_neighbours_.exists(id)) {
94  const NodeSet& set = neighbours(id);
95 
96  for (auto iter = set.beginSafe(); iter != set.endSafe();
97  ++iter) { // safe iterator needed here
99  }
100  }
101  }
102 
103  INLINE bool EdgeGraphPart::operator==(const EdgeGraphPart& p) const {
104  return _edges_ == p._edges_;
105  }
106 
107  INLINE bool EdgeGraphPart::operator!=(const EdgeGraphPart& p) const {
108  return _edges_ != p._edges_;
109  }
110 
111 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643