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
23/* \addtogroup simplex_tree
24 * Represents a set of node of a Simplex_tree that share the same parent.
25 * @{
26 */
27
28/* \brief Data structure to store a set of nodes in a SimplexTree sharing
29 * the same parent node.*/
30template<class SimplexTree, class MapContainer>
31class Simplex_tree_siblings {
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
42 typedef typename SimplexTree::Node Node;
43 typedef MapContainer Dictionary;
44 typedef typename MapContainer::iterator Dictionary_it;
45
46 /* Default constructor.*/
47 Simplex_tree_siblings()
48 : oncles_(nullptr),
49 parent_(-1),
50 members_() {
51 }
52
53 /* Constructor with values.*/
54 Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent)
55 : oncles_(oncles),
56 parent_(parent),
57 members_() {
58 }
59
60 /* \brief Constructor with initialized set of members.
61 *
62 * 'members' must be sorted and unique.*/
63 template<typename RandomAccessVertexRange>
64 Simplex_tree_siblings(Simplex_tree_siblings * oncles, Vertex_handle parent, const RandomAccessVertexRange & members)
65 : oncles_(oncles),
66 parent_(parent),
67 members_(boost::container::ordered_unique_range, members.begin(),
68 members.end()) {
69 for (auto& map_el : members_) {
70 map_el.second.assign_children(this);
71 }
72 }
73
74 /*
75 * \brief Inserts a Node in the set of siblings nodes.
76 *
77 * If already present, assigns the minimal filtration value
78 * between input filtration_value and the value already
79 * present in the node.
80 */
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
116/* @} */ // end addtogroup simplex_tree
117} // namespace Gudhi
118
119#endif // SIMPLEX_TREE_SIMPLEX_TREE_SIBLINGS_H_
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15
GUDHIdev  Version 3.5.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Tue Aug 16 2022 14:01:50 for GUDHIdev by Doxygen 1.9.4