diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-03-20 15:55:02 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-03-20 15:55:02 +0000 |
commit | fe296c664a0655fbc4814c51105570773731fb88 (patch) | |
tree | 0c7b0e14447797ba3e762a768161b840e98989d4 | |
parent | bd9882e11ba5c8602196d416d04849766226e6ed (diff) |
Started tests
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@496 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: cd644bc64c0183dbadb8bbdecde6ccc77e7d3c84
-rw-r--r-- | src/Witness_complex/example/simple_witness_complex.cpp | 29 | ||||
-rw-r--r-- | src/Witness_complex/include/gudhi/Witness_complex.h | 33 |
2 files changed, 37 insertions, 25 deletions
diff --git a/src/Witness_complex/example/simple_witness_complex.cpp b/src/Witness_complex/example/simple_witness_complex.cpp index 5eb39eb0..853918b8 100644 --- a/src/Witness_complex/example/simple_witness_complex.cpp +++ b/src/Witness_complex/example/simple_witness_complex.cpp @@ -33,21 +33,22 @@ typedef std::vector< Vertex_handle > typeVectorVertex; int main (int argc, char * const argv[]) { - Witness_complex<> wc; + Witness_complex<> witnessComplex = Witness_complex<>(); std::vector< typeVectorVertex > KNN; - typeVectorVertex witness0 = {1,7,5,2,6,3,4}; KNN.push_back(witness0 ); - typeVectorVertex witness1 = {2,6,4,5,7,1,3}; KNN.push_back(witness1 ); - typeVectorVertex witness2 = {3,4,2,1,5,6,7}; KNN.push_back(witness2 ); - typeVectorVertex witness3 = {4,2,1,3,5,6,7}; KNN.push_back(witness3 ); - typeVectorVertex witness4 = {5,1,6,7,2,3,4}; KNN.push_back(witness4 ); - typeVectorVertex witness5 = {6,7,5,2,1,3,4}; KNN.push_back(witness5 ); - typeVectorVertex witness6 = {7,5,6,1,2,3,4}; KNN.push_back(witness6 ); - typeVectorVertex witness7 = {2,6,4,5,3,1,7}; KNN.push_back(witness7 ); - typeVectorVertex witness8 = {1,2,5,4,3,6,7}; KNN.push_back(witness8 ); + typeVectorVertex witness0 = {1,0,5,2,6,3,4}; KNN.push_back(witness0 ); + typeVectorVertex witness1 = {2,6,4,5,0,1,3}; KNN.push_back(witness1 ); + typeVectorVertex witness2 = {3,4,2,1,5,6,0}; KNN.push_back(witness2 ); + typeVectorVertex witness3 = {4,2,1,3,5,6,0}; KNN.push_back(witness3 ); + typeVectorVertex witness4 = {5,1,6,0,2,3,4}; KNN.push_back(witness4 ); + typeVectorVertex witness5 = {6,0,5,2,1,3,4}; KNN.push_back(witness5 ); + typeVectorVertex witness6 = {0,5,6,1,2,3,4}; KNN.push_back(witness6 ); + typeVectorVertex witness7 = {2,6,4,5,3,1,0}; KNN.push_back(witness7 ); + typeVectorVertex witness8 = {1,2,5,4,3,6,0}; KNN.push_back(witness8 ); typeVectorVertex witness9 = {3,4,5,2,6,3,4}; KNN.push_back(witness9 ); - typeVectorVertex witness10 = {5,7,1,3,6,2,4}; KNN.push_back(witness10); - typeVectorVertex witness11 = {5,6,1,7,2,3,4}; KNN.push_back(witness11); - typeVectorVertex witness12 = {1,6,7,5,2,3,4}; KNN.push_back(witness12); - wc.witness_complex(KNN); + typeVectorVertex witness10 = {5,0,1,3,6,2,4}; KNN.push_back(witness10); + typeVectorVertex witness11 = {5,6,1,0,2,3,4}; KNN.push_back(witness11); + typeVectorVertex witness12 = {1,6,0,5,2,3,4}; KNN.push_back(witness12); + std::cout << "Let the carnage begin!\n"; + witnessComplex.witness_complex(KNN); std::cout << "Howdy world!\n"; } diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 624b2a51..985660d4 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -33,6 +33,8 @@ #include <list> #include <math.h> +#include <iostream> + namespace Gudhi { /* @@ -143,13 +145,17 @@ public: * Landmarks are supposed to be in [0,nbL-1] */ + template< typename KNearestNeighbours > void witness_complex(KNearestNeighbours & knn) +//void witness_complex(std::vector< std::vector< Vertex_handle > > & knn) { - int k=1; /* current dimension in iterative construction */ + std::cout << "**Start the procedure witness_complex" << std::endl; + int k=2; /* current dimension in iterative construction */ //Construction of the active witness list int nbW = knn.size(); int nbL = knn.at(0).size(); + std::cout << "Eh?\n"; //VertexHandle vh; typeVectorVertex vv; typeSimplex simplex; @@ -164,10 +170,12 @@ void witness_complex(KNearestNeighbours & knn) //vh = (Vertex_handle)i; vv = {i}; /* TODO Filtration */ - simplex = std::make_pair(vv, Filtration_value(0.0)); - returnValue = this->insert_simplex(simplex.first, simplex.second); + //simplex = std::make_pair(vv, Filtration_value(0.0)); + //returnValue = this->insert_simplex(simplex.first, simplex.second); + returnValue = this->insert_simplex(vv, Filtration_value(0.0)); /* TODO Error if not inserted : normally no need here though*/ } + std::cout << "Successfully added landmarks" << std::endl; int u,v; // two extremities of an edge if (nbL > 1) // if the supposed dimension of the complex is >0 for (int i=0; i != nbW; ++i) { @@ -183,22 +191,17 @@ void witness_complex(KNearestNeighbours & knn) vv = {u,v}; returnValue = this->insert_simplex(vv,Filtration_value(0.0)); active_w.push_back(Active_witness(i,v,returnValue.first)); + if (returnValue.second) std::cout << "Added edge " << u << v << std::endl; //Simplex_handle sh = root_.members_.begin()+u; //active_w.push_front(i); } + std::cout << "Successfully added edges" << std::endl; while (!active_w.empty() && k+1 < nbL ) { + std::cout << "Started the step k=" << k << std::endl; typename ActiveWitnessList::iterator it = active_w.begin(); while (it != active_w.end()) { typeVectorVertex simplex_vector; typeVectorVertex suffix; - /* - for (int i=0; i != k; ++i) { - // create a (k+1) element array for the given active witness - simplex_vector.push_back(knn[it->witness_id][i]); - } - - sort(simplex_vector.begin(),simplex_vector.end()); - */ /* THE INSERTION: Checking if all the subfaces are in the simplex tree is mandatory */ bool ok = all_faces_in(knn[it->witness_id][k],it->simplex_handle); if (ok) @@ -206,6 +209,7 @@ void witness_complex(KNearestNeighbours & knn) else active_w.erase(it++); //First increase the iterator and then erase the previous element } + k++; } } @@ -213,16 +217,23 @@ private: bool all_faces_in(VertexHandle last, Simplex_handle sh) { + std::cout << "All face in with the landmark " << last << std::endl; std::list< VertexHandle > suffix; Simplex_handle curr_sh = sh; Siblings * curr_sibl = self_siblings(sh); VertexHandle curr_vh = curr_sh->first; while (curr_vh > last) { + std::cout << "We are at " << curr_vh << "\n"; suffix.push_front(curr_vh); + std::cout << "Still fine 1\n"; curr_vh = curr_sibl->parent(); + std::cout << "Still fine 2\n"; curr_sibl = curr_sibl->oncles(); + std::cout << "Still fine 3\n"; curr_sh = curr_sibl->find(curr_vh); + std::cout << "Still fine 4\n"; } + std::cout << "Arrived at the mid-parent" << std::endl; suffix.push_front(last); typename std::list< VertexHandle >::iterator itVV = suffix.begin(); Simplex_handle sh_bup = curr_sh; // Back up the pointer |