summaryrefslogtreecommitdiff
path: root/src/python/include
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-03-30 17:56:27 +0200
committerGitHub <noreply@github.com>2020-03-30 17:56:27 +0200
commit2f46606b406aafc69e37a68dca33e1858ab7b817 (patch)
tree00fe086be752902c58d9126e9959120f28f06406 /src/python/include
parentc669664a7bdda51d31410b6fa0f7c41e9e616b07 (diff)
parentb2a549c055c2796fe4eb1e4e4265cdd718753416 (diff)
Merge pull request #215 from MathieuCarriere/extended_persistence
Extended persistence
Diffstat (limited to 'src/python/include')
-rw-r--r--src/python/include/Simplex_tree_interface.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/python/include/Simplex_tree_interface.h b/src/python/include/Simplex_tree_interface.h
index 4a7062d6..1a18aed6 100644
--- a/src/python/include/Simplex_tree_interface.h
+++ b/src/python/include/Simplex_tree_interface.h
@@ -37,8 +37,12 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
using Filtered_simplices = std::vector<Simplex_and_filtration>;
using Skeleton_simplex_iterator = typename Base::Skeleton_simplex_iterator;
using Complex_simplex_iterator = typename Base::Complex_simplex_iterator;
+ using Extended_filtration_data = typename Base::Extended_filtration_data;
public:
+
+ Extended_filtration_data efd;
+
bool find_simplex(const Simplex& vh) {
return (Base::find(vh) != Base::null_simplex());
}
@@ -117,6 +121,42 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
return cofaces;
}
+ void compute_extended_filtration() {
+ this->efd = this->extend_filtration();
+ this->initialize_filtration();
+ return;
+ }
+
+ std::vector<std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>> compute_extended_persistence_subdiagrams(const std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>& dgm, Filtration_value min_persistence){
+ std::vector<std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>> new_dgm(4);
+ for (unsigned int i = 0; i < dgm.size(); i++){
+ std::pair<Filtration_value, Extended_simplex_type> px = this->decode_extended_filtration(dgm[i].second.first, this->efd);
+ std::pair<Filtration_value, Extended_simplex_type> py = this->decode_extended_filtration(dgm[i].second.second, this->efd);
+ std::pair<int, std::pair<Filtration_value, Filtration_value>> pd_point = std::make_pair(dgm[i].first, std::make_pair(px.first, py.first));
+ if(std::abs(px.first - py.first) > min_persistence){
+ //Ordinary
+ if (px.second == Extended_simplex_type::UP && py.second == Extended_simplex_type::UP){
+ new_dgm[0].push_back(pd_point);
+ }
+ // Relative
+ else if (px.second == Extended_simplex_type::DOWN && py.second == Extended_simplex_type::DOWN){
+ new_dgm[1].push_back(pd_point);
+ }
+ else{
+ // Extended+
+ if (px.first < py.first){
+ new_dgm[2].push_back(pd_point);
+ }
+ //Extended-
+ else{
+ new_dgm[3].push_back(pd_point);
+ }
+ }
+ }
+ }
+ return new_dgm;
+ }
+
void create_persistence(Gudhi::Persistent_cohomology_interface<Base>* pcoh) {
Base::initialize_filtration();
pcoh = new Gudhi::Persistent_cohomology_interface<Base>(*this);