aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
edgeGraphPart_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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 {
41  return edges__.contains(edge);
42  }
43 
45  const NodeId second) const {
47  }
48 
51  }
52 
60 
62  }
63 
65  if (existsEdge(edge)) {
66  // ASSUMING first and second exists in neighbours__ (if not, it is an
67  // error)
68  NodeId id1 = edge.first(), id2 = edge.second();
69 
74  }
75  }
76 
79  return *(neighbours__[id]);
80  }
81 
83  if (neighbours__.exists(id)) {
84  const NodeSet& set = neighbours(id);
85 
86  for (auto iter = set.beginSafe(); iter != set.endSafe();
87  ++iter) { // safe iterator needed here
88  // warning: use this erase so that you actually use the virtualized
89  // edge removal function
90  eraseEdge(Edge(*iter, id));
91  }
92  }
93  }
94 
96  if (neighbours__.exists(id)) {
97  const NodeSet& set = neighbours(id);
98 
99  for (auto iter = set.beginSafe(); iter != set.endSafe();
100  ++iter) { // safe iterator needed here
102  }
103  }
104  }
105 
106  INLINE bool EdgeGraphPart::operator==(const EdgeGraphPart& p) const {
107  return edges__ == p.edges__;
108  }
109 
110  INLINE bool EdgeGraphPart::operator!=(const EdgeGraphPart& p) const {
111  return edges__ != p.edges__;
112  }
113 
114 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669