Simplex_tree_siblings.h
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author(s): Clément Maria
4 *
5 * Copyright (C) 2014 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
11#ifndef SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
12#define SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
13
14#include <gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h>
15
16#include <boost/container/flat_map.hpp>
17
18namespace Gudhi {
19
27template<class SimplexTree, class MapContainer>
29// private:
30// friend SimplexTree;
31 public:
32 template<class T> friend class Simplex_tree_simplex_vertex_iterator;
33 template<class T> friend class Simplex_tree_boundary_simplex_iterator;
34 template<class T> friend class Simplex_tree_complex_simplex_iterator;
35 template<class T> friend class Simplex_tree_skeleton_simplex_iterator;
36 template<class T> friend class Simplex_tree_boundary_opposite_vertex_simplex_iterator;
37
40 typedef typename SimplexTree::Node Node;
41 typedef MapContainer Dictionary;
42 typedef typename MapContainer::iterator Dictionary_it;
43 typedef typename MapContainer::const_iterator Dictionary_const_it;
44
45 /* Default constructor.*/
47 : oncles_(nullptr),
48 parent_(-1),
49 members_() {
50 }
51
52 /* Constructor with values.*/
54 : oncles_(oncles),
55 parent_(parent),
56 members_() {
57 }
58
62 template<typename RandomAccessVertexRange>
63 Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent, const RandomAccessVertexRange & members)
64 : oncles_(oncles),
65 parent_(parent),
66 members_(boost::container::ordered_unique_range, members.begin(),
67 members.end()) {
68 for (auto& map_el : members_) {
69 map_el.second.assign_children(this);
70 }
71 }
72
79 void insert(Vertex_handle v, Filtration_value filtration_value) {
80 auto ins = members_.emplace(v, Node(this, filtration_value));
81 if (!ins.second && filtration(ins.first) > filtration_value)
82 ins.first->second.assign_filtration(filtration_value);
83 }
84
85 Dictionary_it find(Vertex_handle v) {
86 return members_.find(v);
87 }
88 Dictionary_const_it find(Vertex_handle v) const {
89 return members_.find(v);
90 }
91
92 Simplex_tree_siblings * oncles() {
93 return oncles_;
94 }
95 const Simplex_tree_siblings * oncles() const {
96 return oncles_;
97 }
98
99 Vertex_handle parent() const {
100 return parent_;
101 }
102
103 Dictionary & members() {
104 return members_;
105 }
106
107 const Dictionary & members() const {
108 return members_;
109 }
110
111 size_t size() const {
112 return members_.size();
113 }
114
115 void erase(const Dictionary_it iterator) {
116 members_.erase(iterator);
117 }
118
119 Dictionary_it to_non_const_it(Dictionary_const_it it) {
120 return members_.erase(it, it);
121 }
122
123 Simplex_tree_siblings * oncles_;
124 Vertex_handle parent_;
125 Dictionary members_;
126};
127 // end addtogroup simplex_tree
129
130} // namespace Gudhi
131
132#endif // SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition: Simplex_tree_iterators.h:193
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree_iterators.h:81
Iterator over the simplices of a simplicial complex.
Definition: Simplex_tree_iterators.h:308
Data structure to store a set of nodes in a SimplexTree sharing the same parent node.
Definition: Simplex_tree_siblings.h:28
void insert(Vertex_handle v, Filtration_value filtration_value)
Inserts a Node in the set of siblings nodes.
Definition: Simplex_tree_siblings.h:79
Simplex_tree_siblings(Simplex_tree_siblings *oncles, Vertex_handle parent, const RandomAccessVertexRange &members)
Constructor with initialized set of members.
Definition: Simplex_tree_siblings.h:63
Iterator over the vertices of a simplex in a SimplexTree.
Definition: Simplex_tree_iterators.h:36
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition: Simplex_tree_iterators.h:382
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20
Node of a simplex tree with filtration value and simplex key.
Definition: Simplex_tree_node_explicit_storage.h:40
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15