From 0dcebad6a0c9d9f7968b582522fbbf548758d9c0 Mon Sep 17 00:00:00 2001 From: mcarrier Date: Mon, 26 Feb 2018 12:53:46 +0000 Subject: git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@3257 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 25ee894f17d60c05f961faec7bfa41f510d91827 --- src/Nerve_GIC/include/gudhi/GIC.h | 56 ++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) (limited to 'src/Nerve_GIC') diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 642b88b0..c5fd4d22 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -115,7 +115,7 @@ class Cover_complex { std::vector distribution; std::map > - cover; // function associating to each data point its vectors of cover elements to which it belongs. + cover; // function associating to each data point the vector of cover elements to which it belongs. std::map > cover_back; // inverse of cover, in order to get the data points associated to a specific cover element. std::map cover_std; // standard function (induced by func) used to compute the extended persistence @@ -1044,13 +1044,31 @@ class Cover_complex { minf = std::min(minf, it->second); } + /*int magic[] = {-2}; + st.insert_simplex(magic, -3); + for (auto const& simplex : simplices) { - // Add a simplex and a cone on it - std::vector splx = simplex; - splx.push_back(-2); - st.insert_simplex_and_subfaces(splx); + std::vector splx = simplex; splx.push_back(-2); + st.insert_simplex_and_subfaces(splx, -3); } + for (auto const& simplex : simplices) { + if(simplex.size() == 1){ + st.insert_simplex(it->first, -2 + (it->second - minf)/(maxf - minf)); + int[] cone_edge = {-2,it->first}; + st.insert_simplex(cone_edge, 2 - (it->second - minf)/(maxf - minf)); + } + else{ + st.insert_simplex(simplex, -2.5); + std::vector splx = simplex; splx.push_back(-2); + st.insert_simplex(splx, 0); + } + } + + st.make_filtration_non_decreasing();*/ + + + // Build filtration for (auto simplex : st.complex_simplex_range()) { double filta = std::numeric_limits::lowest(); @@ -1062,7 +1080,7 @@ class Cover_complex { continue; } filta = std::max(-2 + (cover_std[vertex] - minf) / (maxf - minf), filta); - filts = std::max(2 - (cover_std[vertex] - minf) / (maxf - minf), filts); + filts = std::max( 2 - (cover_std[vertex] - minf) / (maxf - minf), filts); } if (ascending) st.assign_filtration(simplex, filta); @@ -1071,11 +1089,10 @@ class Cover_complex { } int magic[] = {-2}; st.assign_filtration(st.find(magic), -3); + st.initialize_filtration(); // Compute PD - st.initialize_filtration(); - Gudhi::persistent_cohomology::Persistent_cohomology pcoh(st); - pcoh.init_coefficients(2); + Gudhi::persistent_cohomology::Persistent_cohomology pcoh(st); pcoh.init_coefficients(2); pcoh.compute_persistent_cohomology(); // Output PD @@ -1201,6 +1218,27 @@ class Cover_complex { } } + private: + std::vector > subfaces(std::vector simplex){ + if (simplex.size() == 1){ + std::vector > dummy; dummy.clear(); + std::vector empty; empty.clear(); + dummy.push_bakc(empty); dummy.push_back(simplex); return dummy; + } + else{ + int popped_vertex = simplex[simplex.size()-1]; + std::vector popped_simplex = simplex; popped_simplex.pop_back(); + std::vector > subf1 = subfaces(popped_simplex); std::vector > subf2; + for (int i = 0; i < subf1.size(); i++){ + std::vector face = subf1[i]; + face.push_back(popped_vertex); + subf2.push_back(face); + } + subf1.insert(subf1.end(), subf2.begin(), subf2.end() ); + return subf1; + } + } + public: /** \brief Computes the simplices of the simplicial complex. */ -- cgit v1.2.3