11 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_
12 #define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLEX_H_
18 #include <initializer_list>
24 namespace skeleton_blocker {
40 std::set<T> simplex_set;
43 typedef typename T::boost_vertex_handle boost_vertex_handle;
45 typedef T Vertex_handle;
47 typedef typename std::set<T>::const_iterator Simplex_vertex_const_iterator;
48 typedef typename std::set<T>::iterator Simplex_vertex_iterator;
59 std::for_each(list.begin(), list.end(), [&] (T
const& elt) {
64 template<
typename ... Args>
66 add_vertices(args...);
69 template<
typename ... Args>
70 void add_vertices(T v, Args ... args) {
72 add_vertices(args...);
75 void add_vertices(T v) {
79 void add_vertices() { }
86 if ((token[0] ==
'{') && (token[token.size() - 1] ==
'}')) {
88 token.erase(token.size() - 1, 1);
89 while (token.size() != 0) {
90 int coma_position = token.find_first_of(
',');
92 std::string n = token.substr(0, coma_position);
94 token.erase(0, n.size() + 1);
111 simplex_set.insert(v);
118 simplex_set.erase(v);
126 v.reserve((std::min)(simplex_set.size(), a.simplex_set.size()));
128 set_intersection(simplex_set.begin(), simplex_set.end(),
129 a.simplex_set.begin(), a.simplex_set.end(),
130 std::back_inserter(v));
133 simplex_set.insert(i);
141 v.reserve(simplex_set.size());
143 set_difference(simplex_set.begin(), simplex_set.end(),
144 a.simplex_set.begin(), a.simplex_set.end(),
145 std::back_inserter(v));
149 simplex_set.insert(i);
157 v.reserve(simplex_set.size() + a.simplex_set.size());
159 set_union(simplex_set.begin(), simplex_set.end(), a.simplex_set.begin(),
160 a.simplex_set.end(), std::back_inserter(v));
162 simplex_set.insert(v.begin(), v.end());
165 typename std::set<T>::const_iterator begin()
const {
166 return simplex_set.cbegin();
169 typename std::set<T>::const_iterator end()
const {
170 return simplex_set.cend();
173 typename std::set<T>::const_reverse_iterator rbegin()
const {
174 return simplex_set.crbegin();
177 typename std::set<T>::const_reverse_iterator rend()
const {
178 return simplex_set.crend();
181 typename std::set<T>::iterator begin() {
182 return simplex_set.begin();
185 typename std::set<T>::iterator end() {
186 return simplex_set.end();
198 return (simplex_set.size() - 1);
202 return simplex_set.empty();
222 return *(simplex_set.rbegin());
229 return includes(simplex_set.cbegin(), simplex_set.cend(),
230 a.simplex_set.cbegin(), a.simplex_set.cend());
238 auto first1 = begin();
241 auto first2 = a.begin();
242 auto last2 = a.end();
244 while (first2 != last2) {
249 if ((first1 == last1) || (*first2 < *first1))
251 if (!(*first1 < *first2))
263 auto first1 = begin();
266 auto first2 = a.begin();
267 auto last2 = a.end();
269 while (first2 != last2) {
274 if ((first1 == last1) || (*first2 < *first1))
276 if (!(*first1 < *first2))
288 auto first1 = begin();
291 auto first2 = a.begin();
292 auto last2 = a.end();
294 while (first2 != last2) {
296 if (x == *first2 || y == *first2) {
299 if ((first1 == last1) || (*first2 < *first1))
301 if (!(*first1 < *first2))
310 return (simplex_set.find(v) != simplex_set.end());
313 bool disjoint(
const Skeleton_blocker_simplex& a)
const {
315 v.reserve(std::min(simplex_set.size(), a.simplex_set.size()));
317 set_intersection(simplex_set.cbegin(), simplex_set.cend(),
318 a.simplex_set.cbegin(), a.simplex_set.cend(),
319 std::back_inserter(v));
321 return (v.size() == 0);
324 bool operator==(
const Skeleton_blocker_simplex& other)
const {
325 return (this->simplex_set == other.simplex_set);
328 bool operator!=(
const Skeleton_blocker_simplex& other)
const {
329 return (this->simplex_set != other.simplex_set);
332 bool operator<(
const Skeleton_blocker_simplex& other)
const {
333 return (std::lexicographical_compare(this->simplex_set.begin(),
334 this->simplex_set.end(), other.begin(),
340 friend std::ostream& operator<<(std::ostream& o,
341 const Skeleton_blocker_simplex & sigma) {
344 for (
auto i : sigma) {
358 namespace skbl = skeleton_blocker;
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:38
T first_vertex() const
Definition: Skeleton_blocker_simplex.h:210
bool contains_difference(const Skeleton_blocker_simplex &a, T x, T y) const
Definition: Skeleton_blocker_simplex.h:287
void union_vertices(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:155
bool contains(const Skeleton_blocker_simplex &a) const
Definition: Skeleton_blocker_simplex.h:228
void intersection(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:124
Skeleton_blocker_simplex(std::string token)
Definition: Skeleton_blocker_simplex.h:84
T last_vertex() const
Definition: Skeleton_blocker_simplex.h:220
void remove_vertex(T v)
Definition: Skeleton_blocker_simplex.h:117
bool contains_difference(const Skeleton_blocker_simplex &a, T x) const
Definition: Skeleton_blocker_simplex.h:262
bool contains_difference(const Skeleton_blocker_simplex &a, const Skeleton_blocker_simplex &b) const
Definition: Skeleton_blocker_simplex.h:236
void difference(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:139
int dimension() const
Definition: Skeleton_blocker_simplex.h:197
void add_vertex(T v)
Definition: Skeleton_blocker_simplex.h:110
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14