summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/include/gudhi/Simplex_tree.h
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-07-03 16:04:45 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-07-03 16:04:45 +0200
commit85eec1ba750d56b66e3739dc486c6205f49fb31e (patch)
tree74053406d8f1d5ebbf2b6d51c6b8c6f7931b566e /src/Simplex_tree/include/gudhi/Simplex_tree.h
parent444ec77fe16783c35ef86598011a662c5d6e8d92 (diff)
A proposal for simplex_tree reset_filtration (python & C++)
Diffstat (limited to 'src/Simplex_tree/include/gudhi/Simplex_tree.h')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 889dbd00..adc8e801 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -1667,6 +1667,36 @@ class Simplex_tree {
return sh; // None of its faces has the same filtration.
}
+ public:
+ /** \brief This function resets filtration value until a given dimension.
+ * @param[in] filt_value The new filtration value.
+ * @param[in] max_dim The maximal dimension.
+ */
+ void reset_filtration(Filtration_value filt_value, int max_dim) {
+ for (auto& simplex : root_.members()) {
+ simplex.second.assign_filtration(filt_value);
+ if (has_children(&simplex) && max_dim > 0) {
+ rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1));
+ }
+ }
+ clear_filtration(); // Drop the cache.
+ }
+
+ private:
+ /** \brief Recursively resets filtration value until a given dimension.
+ * @param[in] sib Siblings to be parsed.
+ * @param[in] filt_value The new filtration value.
+ * @param[in] max_dim The maximal dimension.
+ */
+ void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int max_dim) {
+ for (auto& simplex : sib->members()) {
+ simplex.second.assign_filtration(filt_value);
+ if (has_children(&simplex) && max_dim > 0) {
+ rec_reset_filtration(simplex.second.children(), filt_value, (max_dim - 1));
+ }
+ }
+ }
+
private:
Vertex_handle null_vertex_;
/** \brief Total number of simplices in the complex, without the empty simplex.*/