summaryrefslogtreecommitdiff
path: root/src/Simplex_tree
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-23 23:04:43 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-23 23:04:43 +0000
commit73d8be19b7834f500e38f7304fd01e0e641ef018 (patch)
treebec4556fe92973dc44665932bfd056cc71bec2a0 /src/Simplex_tree
parentbbf22c32a893c9875f6ea0e217d0bf6cf77c3257 (diff)
An alternative to prune_above_filtration in comment. Fix UT for alternative
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@1072 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1958a5ee06c339d8cd8cdaae92358d2fff445a7a
Diffstat (limited to 'src/Simplex_tree')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index af298f33..1bad8d7d 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -1219,37 +1219,39 @@ class Simplex_tree {
return (simplex_list_to_removed.size() > 0);
}
- /*
+
// Another alternative for prune_above_filtration
- // initialize_filtration is not called. UT are not passed.
- void prune_above_filtration(Filtration_value filt) {
- if (!Options::store_filtration || filt >= filtration()) return;
- rec_prune_above_filtration(root(), filt);
- set_filtration(filt);
+ // UT are passed and performance are similar.
+ /*bool prune_above_filtration(Filtration_value filt) {
+ return rec_prune_above_filtration(root(), filt);
}
private:
- void rec_prune_above_filtration(Siblings* sib, Filtration_value filt) {
+ bool rec_prune_above_filtration(Siblings* sib, Filtration_value filt) {
auto&& list=sib->members();
auto last = std::remove_if(list.begin(), list.end(), [=](Dit_value_t& simplex) {
- if (simplex.second.filtration()<=filt) return false;
- if (has_children(&simplex)) rec_delete(simplex.second.children());
- return true;
+ if (simplex.second.filtration()<=filt) return false;
+ if (has_children(&simplex)) rec_delete(simplex.second.children());
+ return true;
});
-
+
+ bool modified = (last != list.end());
if (last == list.begin() && sib != root()) {
// Removing the whole siblings, parent becomes a leaf.
sib->oncles()->members()[sib->parent()].assign_children(sib->oncles());
delete sib;
+ return true;
} else {
// Keeping some elements of siblings. Remove the others, and recurse in the remaining ones.
list.erase(last, list.end());
for(auto&& simplex : list)
if(has_children(&simplex))
- rec_prune_above_filtration(simplex.second.children(), filt);
+ modified |= rec_prune_above_filtration(simplex.second.children(), filt);
}
+ return modified;
}*/
+ public:
/** \brief Remove a maximal simplex.
* @param[in] sh Simplex handle on the maximal simplex to remove.
* \pre Please check the simplex has no coface before removing it.