From 62861adfd2de672d3d90e2fbade499fe76e5bca7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Apr 2018 06:50:12 +0000 Subject: persistence_pairs Python version git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/python_2.1.0_fix_vincent@3393 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5ee633545ca5754b605cdd789ca9720f5936998a --- .../include/Persistent_cohomology_interface.h | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/cython/include/Persistent_cohomology_interface.h') diff --git a/src/cython/include/Persistent_cohomology_interface.h b/src/cython/include/Persistent_cohomology_interface.h index 55028fd0..e8889444 100644 --- a/src/cython/include/Persistent_cohomology_interface.h +++ b/src/cython/include/Persistent_cohomology_interface.h @@ -85,6 +85,32 @@ persistent_cohomology::Persistent_cohomology, std::vector>> persistence_pairs() { + auto pairs = persistent_cohomology::Persistent_cohomology::get_persistent_pairs(); + + std::vector, std::vector>> persistence_pairs; + persistence_pairs.reserve(pairs.size()); + for (auto pair : pairs) { + std::vector birth; + if (get<0>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<0>(pair))) { + birth.push_back(vertex); + } + } + + std::vector death; + if (get<1>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<1>(pair))) { + death.push_back(vertex); + } + } + + persistence_pairs.push_back(std::make_pair(birth,death)); + } + return persistence_pairs; + } + private: // A copy FilteredComplex* stptr_; -- cgit v1.2.3