diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-06-03 08:40:22 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-06-03 08:40:22 +0000 |
commit | 5f049ec0dbf0f756d8ecc5e55b00d2bd748cb927 (patch) | |
tree | 9053d176d18d0cbc0b6d034ec1abbf384b668609 /src/Witness_complex | |
parent | 9e99b02fa2d91aced59c5fded3f1a2e07afe30aa (diff) |
witness: Added good-bad link count to witness_complex_perturbations
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@602 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: b4dbfbf4f8c59399b174574216b577075f08ede8
Diffstat (limited to 'src/Witness_complex')
-rw-r--r-- | src/Witness_complex/example/witness_complex_perturbations.cpp | 20 | ||||
-rw-r--r-- | src/Witness_complex/include/gudhi/Witness_complex.h | 14 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/Witness_complex/example/witness_complex_perturbations.cpp b/src/Witness_complex/example/witness_complex_perturbations.cpp index 9d39906b..ec7a5abe 100644 --- a/src/Witness_complex/example/witness_complex_perturbations.cpp +++ b/src/Witness_complex/example/witness_complex_perturbations.cpp @@ -292,6 +292,8 @@ int landmark_perturbation(Point_Vector &W, Point_Vector& landmarks, std::vector< if (dist < lambda) lambda = dist; } + //std::cout << "\nBad links total: " << count_badlinks << " Points to perturb: " << perturbL.size() << std::endl; + } //std::cout << "\n"; @@ -307,14 +309,16 @@ int landmark_perturbation(Point_Vector &W, Point_Vector& landmarks, std::vector< std::cout << "Entered bad links\n"; std::set< int > perturbL; int count_badlinks = 0; - std::cout << "Bad links around "; + std::vector< int > count_bad(D); + std::vector< int > count_good(D); + //std::cout << "Bad links around "; for (auto u: witnessComplex.complex_vertex_range()) - if (!witnessComplex.has_good_link(u)) + if (!witnessComplex.has_good_link(u, count_bad, count_good)) { //std::cout << "Landmark " << u << " start!" << std::endl; //perturbL.insert(u); count_badlinks++; - std::cout << u << " "; + //std::cout << u << " "; Point_d& l = landmarks[u]; Fuzzy_sphere fs(l, sqrt(lambda)*2, 0, STraits(&(landmarks[0]))); L.search(std::insert_iterator<std::set<int>>(perturbL,perturbL.begin()),fs); @@ -322,7 +326,13 @@ int landmark_perturbation(Point_Vector &W, Point_Vector& landmarks, std::vector< //L.search(std::ostream_iterator<int>(std::cout,"\n"),fs); //std::cout << "PerturbL size is " << perturbL.size() << std::endl; } - std::cout << "\nBad links total: " << count_badlinks << " Points to perturb: " << perturbL.size() << std::endl; + for (unsigned int i = 0; i != count_good.size(); i++) + if (count_good[i] != 0) + std::cout << "count_good[" << i << "] = " << count_good[i] << std::endl; + for (unsigned int i = 0; i != count_bad.size(); i++) + if (count_bad[i] != 0) + std::cout << "count_bad[" << i << "] = " << count_bad[i] << std::endl; + std::cout << "Bad links total: " << count_badlinks << " Points to perturb: " << perturbL.size() << std::endl; //std::cout << "landmark[0][0] before" << landmarks[0][0] << std::endl; //*********************** Perturb bad link landmarks @@ -405,7 +415,7 @@ int main (int argc, char * const argv[]) { file_name.erase(0, last_slash_idx + 1); } - write_points("landmarks/initial_pointset",point_vector); + //write_points("landmarks/initial_pointset",point_vector); write_points("landmarks/initial_landmarks",L); for (int i = 0; bl != 0; i++) { diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 0888c086..222e379c 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -641,8 +641,11 @@ private: } // Find the dimension typeVectorVertex init_simplex = {star_vertices[0]}; - int d = star_dim(star_vertices, star_vertices.begin()+1, 0, init_simplex) - 1; //link_dim = star_dim - 1 + bool is_pure = true; + int d = star_dim(star_vertices, star_vertices.begin()+1, 0, init_simplex, is_pure) - 1; //link_dim = star_dim - 1 assert(init_simplex.size() == 1); + if (!is_pure) + std::cout << "Found an impure star around " << v << "\n"; /* if (d == count_good.size()) { @@ -651,7 +654,7 @@ private: } */ if (d == -1) bad_count[0]++; - bool b= (link_is_pseudomanifold(star_vertices,d)); + bool b= (is_pure && link_is_pseudomanifold(star_vertices,d)); if (d != -1) {if (b) good_count[d]++; else bad_count[d]++;} return (d != -1 && b); @@ -713,7 +716,8 @@ private: int star_dim(std::vector< Vertex_handle >& star_vertices, typename std::vector< Vertex_handle >::iterator curr_v, int curr_d, - typeVectorVertex& curr_simplex) + typeVectorVertex& curr_simplex, + bool& is_pure) { //std::cout << "Entered star_dim for " << *(curr_v-1) << "\n"; Simplex_handle sh; @@ -733,7 +737,9 @@ private: if (sh != null_simplex()) { //std::cout << " -> " << *it << "\n"; - int d = star_dim(star_vertices, it+1, curr_d+1, curr_simplex); + int d = star_dim(star_vertices, it+1, curr_d+1, curr_simplex, is_pure); + if (it != curr_v && d != final_d) //If the dimension is known and differs from the one computed previously + is_pure = false; //the simplex is not pure if (d >= final_d) { final_d = d; |