Loading...
Searching...
No Matches
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
18#include <utility>
19#include <vector>
20
21namespace Gudhi {
22
30template<class SimplexTree, class MapContainer>
32// private:
33// friend SimplexTree;
34 public:
35 template<class T> friend class Simplex_tree_simplex_vertex_iterator;
36 template<class T> friend class Simplex_tree_boundary_simplex_iterator;
37 template<class T> friend class Simplex_tree_complex_simplex_iterator;
38 template<class T> friend class Simplex_tree_skeleton_simplex_iterator;
39 template<class T> friend class Simplex_tree_boundary_opposite_vertex_simplex_iterator;
40
43 typedef typename SimplexTree::Node Node;
44 typedef MapContainer Dictionary;
45 typedef typename MapContainer::iterator Dictionary_it;
46
47 /* Default constructor.*/
49 : oncles_(nullptr),
50 parent_(-1),
51 members_() {
52 }
53
54 /* Constructor with values.*/
56 : oncles_(oncles),
57 parent_(parent),
58 members_() {
59 }
60
64 template<typename RandomAccessVertexRange>
65 Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent, const RandomAccessVertexRange & members)
66 : oncles_(oncles),
67 parent_(parent),
68 members_(boost::container::ordered_unique_range, members.begin(),
69 members.end()) {
70 for (auto& map_el : members_) {
71 map_el.second.assign_children(this);
72 }
73 }
74
81 void insert(Vertex_handle v, Filtration_value filtration_value) {
82 auto ins = members_.emplace(v, Node(this, filtration_value));
83 if (!ins.second && filtration(ins.first) > filtration_value)
84 ins.first->second.assign_filtration(filtration_value);
85 }
86
87 Dictionary_it find(Vertex_handle v) {
88 return members_.find(v);
89 }
90
91 Simplex_tree_siblings * oncles() {
92 return oncles_;
93 }
94
95 Vertex_handle parent() const {
96 return parent_;
97 }
98
99 Dictionary & members() {
100 return members_;
101 }
102
103 size_t size() const {
104 return members_.size();
105 }
106
107 void erase(const Dictionary_it iterator) {
108 members_.erase(iterator);
109 }
110
111 Simplex_tree_siblings * oncles_;
112 Vertex_handle parent_;
113 Dictionary members_;
114};
115 // end addtogroup simplex_tree
117
118} // namespace Gudhi
119
120#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:194
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree_iterators.h:82
Iterator over the simplices of a simplicial complex.
Definition: Simplex_tree_iterators.h:309
Data structure to store a set of nodes in a SimplexTree sharing the same parent node.
Definition: Simplex_tree_siblings.h:31
void insert(Vertex_handle v, Filtration_value filtration_value)
Inserts a Node in the set of siblings nodes.
Definition: Simplex_tree_siblings.h:81
Simplex_tree_siblings(Simplex_tree_siblings *oncles, Vertex_handle parent, const RandomAccessVertexRange &members)
Constructor with initialized set of members.
Definition: Simplex_tree_siblings.h:65
Iterator over the vertices of a simplex in a SimplexTree.
Definition: Simplex_tree_iterators.h:37
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition: Simplex_tree_iterators.h:383
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:38
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15