From 9325765e94b1bd43600fe345a033216bce55873f Mon Sep 17 00:00:00 2001 From: skachano Date: Mon, 7 Dec 2015 15:00:41 +0000 Subject: Removed things from Witness_complex.h git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@935 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 00450ae8c849a35d5adc9baa3f35ef8fae1b664a --- .../include/gudhi/Witness_complex.h | 632 +-------------------- 1 file changed, 3 insertions(+), 629 deletions(-) (limited to 'src') diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 201d6525..8316fe3e 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -39,12 +39,6 @@ #include #include -// Needed for nearest neighbours -//#include -//#include -//#include -//#include - // Needed for the adjacency graph in bad link search #include #include @@ -53,8 +47,7 @@ namespace Gudhi { - /** \addtogroup simplex_tree - * Witness complex is a simplicial complex defined on two sets of points in \f$\mathbf{R}^D\f$: + /** Witness complex is a simplicial complex defined on two sets of points in \f$\mathbf{R}^D\f$: * \f$W\f$ set of witnesses and \f$L \subseteq W\f$ set of landmarks. The simplices are based on points in \f$L\f$ * and a simplex belongs to the witness complex if and only if it is witnessed (there exists a point \f$w \in W\f$ such that * w is closer to the vertices of this simplex than others) and all of its faces are witnessed as well. @@ -107,12 +100,8 @@ namespace Gudhi { typedef std::list< Vertex_handle > ActiveWitnessList; private: - /** Number of landmarks - */ - int nbL; - /** Desired density - */ - double density; + int nbL; // Number of landmarks + double density; // Desired density public: @@ -142,7 +131,6 @@ namespace Gudhi { std::cout << "**Start the procedure witness_complex" << std::endl; //Construction of the active witness list int nbW = knn.size(); - //int nbL = knn.at(0).size(); typeVectorVertex vv; typeSimplex simplex; typePairSimplexBool returnValue; @@ -160,60 +148,13 @@ namespace Gudhi { /* TODO Error if not inserted : normally no need here though*/ } int k=1; /* current dimension in iterative construction */ - //std::cout << "Successfully added landmarks" << std::endl; - // PRINT2 - //print_sc(root()); std::cout << std::endl; - /* - int u,v; // two extremities of an edge - int count = 0; - if (nbL > 1) // if the supposed dimension of the complex is >0 - { - for (int i=0; i != nbW; ++i) - { - // initial fill of active witnesses list - u = knn[i][0]; - v = knn[i][1]; - vv = {u,v}; - returnValue = this->insert_simplex(vv,Filtration_value(0.0)); - if (returnValue.second) - count++; - //print_sc(root()); std::cout << std::endl; - //std::cout << "Added edges" << std::endl; - } - std::cout << "The number of edges = " << count << std::endl; - count = 0; - //print_sc(root()); - for (int i=0; i != nbW; ++i) - { - // initial fill of active witnesses list - u = knn[i][0]; - v = knn[i][1]; - if ( u > v) - { - u = v; - v = knn[i][0]; - knn[i][0] = knn[i][1]; - knn[i][1] = v; - } - Simplex_handle sh; - vv = {u,v}; - //if (u==v) std::cout << "Bazzinga!\n"; - sh = (root()->find(u))->second.children()->find(v); - active_w.push_back(i); - } - } - */ for (int i=0; i != nbW; ++i) active_w.push_back(i); std::cout << "k=0, active witnesses: " << active_w.size() << std::endl; //std::cout << "Successfully added edges" << std::endl; - count_good = {0}; - count_bad = {0}; int D = knn[0].size(); while (!active_w.empty() && k < D ) { - count_good.push_back(0); - count_bad.push_back(0); //std::cout << "Started the step k=" << k << std::endl; typename ActiveWitnessList::iterator it = active_w.begin(); while (it != active_w.end()) @@ -232,23 +173,9 @@ namespace Gudhi { active_w.erase(it++); //First increase the iterator and then erase the previous element } std::cout << "k=" << k << ", active witnesses: " << active_w.size() << std::endl; - //std::cout << "** k=" << k << ", num_simplices: " < > WL; - // landmark_choice_by_random_points(point_vector, point_vector.size(), WL); - // witness_complex(WL); - // } private: @@ -390,9 +317,6 @@ private: template void landmark_choice_by_furthest_points(Point_Vector &W, int nbP, KNearestNeighbours &WL) { - //std::cout << "Enter landmark_choice_by_furthest_points "<< std::endl; - //std::cout << "W="; print_vvector(W); - //double density = 5.; Point_Vector wit_land_dist(nbP,std::vector()); // distance matrix witness x landmarks typeVectorVertex chosen_landmarks; // landmark list @@ -402,7 +326,6 @@ private: double curr_dist; // used to stock the distance from the current point to L double infty = std::numeric_limits::infinity(); // infinity (see next entry) std::vector< double > dist_to_L(nbP,infty); // vector of current distances to L from points - // double mindist = infty; int curr_max_w=0; // the point currently furthest from L int j; int temp_swap_int; @@ -418,30 +341,18 @@ private: { //curr_max_w at this point is the next landmark chosen_landmarks.push_back(curr_max_w); - //std::cout << "**********Entered loop with current number of landmarks = " << current_number_of_landmarks << std::endl; - //std::cout << "WL="; print_vvector(WL); - //std::cout << "WLD="; print_vvector(wit_land_dist); - //std::cout << "landmarks="; print_vector(chosen_landmarks); std::cout << std::endl; for (auto v: WL) v.push_back(current_number_of_landmarks); for (int i = 0; i < nbP; ++i) { - // iteration on points in W. update of distance vectors - - //std::cout << "In the loop with i=" << i << " and landmark=" << chosen_landmarks[current_number_of_landmarks] << std::endl; - //std::cout << "W[i]="; print_vector(W[i]); std::cout << " W[landmark]="; print_vector(W[chosen_landmarks[current_number_of_landmarks]]); std::cout << std::endl; curr_dist = euclidean_distance(W[i],W[chosen_landmarks[current_number_of_landmarks]]); - //std::cout << "The problem is not in distance function\n"; wit_land_dist[i].push_back(curr_dist); WL[i].push_back(current_number_of_landmarks); - //std::cout << "Push't back\n"; if (curr_dist < dist_to_L[i]) dist_to_L[i] = curr_dist; j = current_number_of_landmarks; - //std::cout << "First half complete\n"; while (j > 0 && wit_land_dist[i][j-1] > wit_land_dist[i][j]) { - // sort the closest landmark vector for every witness temp_swap_int = WL[i][j]; WL[i][j] = WL[i][j-1]; WL[i][j-1] = temp_swap_int; @@ -450,12 +361,7 @@ private: wit_land_dist[i][j-1] = temp_swap_double; --j; } - //std::cout << "result WL="; print_vvector(WL); - //std::cout << "result WLD="; print_vvector(wit_land_dist); - //std::cout << "result distL="; print_vector(dist_to_L); std::cout << std::endl; - //std::cout << "End loop\n"; } - //std::cout << "Distance to landmarks="; print_vector(dist_to_L); std::cout << std::endl; curr_max_dist = 0; for (int i = 0; i < nbP; ++i) { if (dist_to_L[i] > curr_max_dist) @@ -464,76 +370,9 @@ private: curr_max_w = i; } } - //std::cout << "Chose " << curr_max_w << " as new landmark\n"; } - //std::cout << endl; } - /** \brief Landmark choice strategy by taking random vertices for landmarks. - * - */ - - // template - // void landmark_choice_by_random_points(Point_Vector &W, int nbP, KNearestNeighbours &WL) - // { - // std::cout << "Enter landmark_choice_by_random_points "<< std::endl; - // //std::cout << "W="; print_vvector(W); - // std::unordered_set< int > chosen_landmarks; // landmark set - - // Point_Vector wit_land_dist(nbP,std::vector()); // distance matrix witness x landmarks - - // WL = KNearestNeighbours(nbP,std::vector()); - // int current_number_of_landmarks=0; // counter for landmarks - - // srand(24660); - // int chosen_landmark = rand()%nbP; - // double curr_dist; - - // //int j; - // //int temp_swap_int; - // //double temp_swap_double; - - - // for (current_number_of_landmarks = 0; current_number_of_landmarks != nbL; current_number_of_landmarks++) - // { - // while (chosen_landmarks.find(chosen_landmark) != chosen_landmarks.end()) - // { - // srand((int)clock()); - // chosen_landmark = rand()% nbP; - // //std::cout << chosen_landmark << "\n"; - // } - // chosen_landmarks.insert(chosen_landmark); - // //std::cout << "**********Entered loop with current number of landmarks = " << current_number_of_landmarks << std::endl; - // //std::cout << "WL="; print_vvector(WL); - // //std::cout << "WLD="; print_vvector(wit_land_dist); - // //std::cout << "landmarks="; print_vector(chosen_landmarks); std::cout << std::endl; - // for (auto v: WL) - // v.push_back(current_number_of_landmarks); - // for (int i = 0; i < nbP; ++i) - // { - // // iteration on points in W. update of distance vectors - - // //std::cout << "In the loop with i=" << i << " and landmark=" << chosen_landmarks[current_number_of_landmarks] << std::endl; - // //std::cout << "W[i]="; print_vector(W[i]); std::cout << " W[landmark]="; print_vector(W[chosen_landmarks[current_number_of_landmarks]]); std::cout << std::endl; - // curr_dist = euclidean_distance(W[i],W[chosen_landmark]); - // //std::cout << "The problem is not in distance function\n"; - // wit_land_dist[i].push_back(curr_dist); - // WL[i].push_back(current_number_of_landmarks); - // //std::cout << "Push't back\n"; - // //j = current_number_of_landmarks; - // //std::cout << "First half complete\n"; - // //std::cout << "result WL="; print_vvector(WL); - // //std::cout << "result WLD="; print_vvector(wit_land_dist); - // //std::cout << "End loop\n"; - // } - // } - // for (int i = 0; i < nbP; i++) - // { - // sort(WL[i].begin(), WL[i].end(), [&](int j1, int j2){return wit_land_dist[i][j1] < wit_land_dist[i][j2];}); - // } - // //std::cout << endl; - // } - /** \brief Landmark choice strategy by taking random vertices for landmarks. * */ @@ -541,59 +380,19 @@ private: // template void landmark_choice_by_random_points(Point_Vector &W, int nbP, std::set &L) { - std::cout << "Enter landmark_choice_by_random_points "<< std::endl; - //std::cout << "W="; print_vvector(W); - //std::unordered_set< int > chosen_landmarks; // landmark set - - //Point_Vector wit_land_dist(nbP,std::vector()); // distance matrix witness x landmarks - - //WL = KNearestNeighbours(nbP,std::vector()); int current_number_of_landmarks=0; // counter for landmarks srand(24660); int chosen_landmark = rand()%nbP; - //double curr_dist; - //int j; - //int temp_swap_int; - //double temp_swap_double; for (current_number_of_landmarks = 0; current_number_of_landmarks != nbL; current_number_of_landmarks++) { while (L.find(chosen_landmark) != L.end()) { srand((int)clock()); chosen_landmark = rand()% nbP; - //std::cout << chosen_landmark << "\n"; } L.insert(chosen_landmark); - //std::cout << "**********Entered loop with current number of landmarks = " << current_number_of_landmarks << std::endl; - //std::cout << "WL="; print_vvector(WL); - //std::cout << "WLD="; print_vvector(wit_land_dist); - //std::cout << "landmarks="; print_vector(chosen_landmarks); std::cout << std::endl; - // for (auto v: WL) - // v.push_back(current_number_of_landmarks); - // for (int i = 0; i < nbP; ++i) - // { - // // iteration on points in W. update of distance vectors - - // //std::cout << "In the loop with i=" << i << " and landmark=" << chosen_landmarks[current_number_of_landmarks] << std::endl; - // //std::cout << "W[i]="; print_vector(W[i]); std::cout << " W[landmark]="; print_vector(W[chosen_landmarks[current_number_of_landmarks]]); std::cout << std::endl; - // curr_dist = euclidean_distance(W[i],W[chosen_landmark]); - // //std::cout << "The problem is not in distance function\n"; - // wit_land_dist[i].push_back(curr_dist); - // WL[i].push_back(current_number_of_landmarks); - // //std::cout << "Push't back\n"; - // //j = current_number_of_landmarks; - // //std::cout << "First half complete\n"; - // //std::cout << "result WL="; print_vvector(WL); - // //std::cout << "result WLD="; print_vvector(wit_land_dist); - // //std::cout << "End loop\n"; - // } } - // for (int i = 0; i < nbP; i++) - // { - // sort(WL[i].begin(), WL[i].end(), [&](int j1, int j2){return wit_land_dist[i][j1] < wit_land_dist[i][j2];}); - // } - //std::cout << endl; } @@ -610,7 +409,6 @@ private: typedef bool (*comp)(dist_i,dist_i); for (int W_i = 0; W_i < nbP; W_i++) { - //std::cout << "<<<<<<<<<<<<<<" << W_i <<"\n"; std::priority_queue, comp> l_heap([&](dist_i j1, dist_i j2){return j1.first > j2.first;}); std::set::iterator L_it; int L_i; @@ -623,437 +421,13 @@ private: { dist_i dist = l_heap.top(); WL[W_i].push_back(dist.second); - //WL[W_i].insert(WL[W_i].begin(),dist.second); - //std::cout << dist.first << " " << dist.second << std::endl; l_heap.pop(); } } } - /** \brief Returns true if the link is good - */ - bool has_good_link(Vertex_handle v, std::vector< int >& bad_count, std::vector< int >& good_count) - { - std::vector< Vertex_handle > star_vertices; - // Fill star_vertices - star_vertices.push_back(v); - for (auto u: complex_vertex_range()) - { - typeVectorVertex edge = {u,v}; - if (u != v && find(edge) != null_simplex()) - star_vertices.push_back(u); - } - // Find the dimension - typeVectorVertex init_simplex = {star_vertices[0]}; - bool is_pure = true; - std::vector dim_coface(star_vertices.size(), 1); - int d = star_dim(star_vertices, star_vertices.begin()+1, 0, init_simplex, dim_coface.begin()+1) - 1; //link_dim = star_dim - 1 - assert(init_simplex.size() == 1); - if (!is_pure) - std::cout << "Found an impure star around " << v << "\n"; - for (int dc: dim_coface) - is_pure = (dc == dim_coface[0]); - /* - if (d == count_good.size()) - { - std::cout << "Found a star of dimension " << (d+1) << " around " << v << "\nThe star is "; - print_vector(star_vertices); std::cout << std::endl; - } - */ - //if (d == -1) bad_count[0]++; - bool b= (is_pure && link_is_pseudomanifold(star_vertices,d)); - if (d != -1) {if (b) good_count[d]++; else bad_count[d]++;} - if (!is_pure) bad_count[0]++; - return (d != -1 && b && is_pure); - - } - - /** \brief Search and output links around vertices that are not pseudomanifolds - * - */ - /* - void write_bad_links(std::ofstream& out_file) - { - out_file << "Bad links list\n"; - std::cout << "Entered write_bad_links\n"; - for (auto v: complex_vertex_range()) - { - std::cout << "Vertex " << v << ": "; - std::vector< Vertex_handle > link_vertices; - // Fill link_vertices - for (auto u: complex_vertex_range()) - { - typeVectorVertex edge = {u,v}; - if (u != v && find(edge) != null_simplex()) - link_vertices.push_back(u); - } - - print_vector(link_vertices); - std::cout << "\n"; - - // Find the dimension - typeVectorVertex empty_simplex = {}; - int d = link_dim(link_vertices, link_vertices.begin(),-1, empty_simplex); - if (link_is_pseudomanifold(link_vertices,d)) - count_good[d]++; - } - nc = nbL; - for (unsigned int i = 0; i != count_good.size(); i++) - { - out_file << "count_good[" << i << "] = " << count_good[i] << std::endl; - nc -= count_good[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++) - { - out_file << "count_bad[" << i << "] = " << count_bad[i] << std::endl; - nc -= count_bad[i]; - if (count_bad[i] != 0) - std::cout << "count_bad[" << i << "] = " << count_bad[i] << std::endl; - } - std::cout << "not_connected = " << nc << std::endl; - } - */ - private: - - std::vector count_good; - std::vector count_bad; - int nc; - - int star_dim(std::vector< Vertex_handle >& star_vertices, - typename std::vector< Vertex_handle >::iterator curr_v, - int curr_d, - typeVectorVertex& curr_simplex, - typename std::vector< int >::iterator curr_dc) - { - //std::cout << "Entered star_dim for " << *(curr_v-1) << "\n"; - Simplex_handle sh; - int final_d = curr_d; - typename std::vector< Vertex_handle >::iterator it; - typename std::vector< Vertex_handle >::iterator dc_it; - //std::cout << "Current vertex is " << - for (it = curr_v, dc_it = curr_dc; it != star_vertices.end(); ++it, ++dc_it) - { - curr_simplex.push_back(*it); - typeVectorVertex curr_simplex_copy(curr_simplex); - /* - std::cout << "Searching for "; - print_vector(curr_simplex); - std::cout << " curr_dim " << curr_d << " final_dim " << final_d; - */ - sh = find(curr_simplex_copy); //Need a copy because find sorts the vector and I want star center to be the first - if (sh != null_simplex()) - { - //std::cout << " -> " << *it << "\n"; - int d = star_dim(star_vertices, it+1, curr_d+1, curr_simplex, dc_it); - if (d >= final_d) - { - final_d = d; - //std::cout << d << " "; - //print_vector(curr_simplex); - //std::cout << std::endl; - } - if (d >= *dc_it) - *dc_it = d; - } - /* - else - std::cout << "\n"; - */ - curr_simplex.pop_back(); - } - return final_d; - } - - // color is false is a (d-1)-dim face, true is a d-dim face - //typedef bool Color; - // graph is an adjacency list - typedef typename boost::adjacency_list Adj_graph; - // map that gives to a certain simplex its node in graph and its dimension - //typedef std::pair Reference; - typedef boost::graph_traits::vertex_descriptor Vertex_t; - typedef boost::graph_traits::edge_descriptor Edge_t; - typedef boost::graph_traits::adjacency_iterator Adj_it; - typedef std::pair Out_edge_it; - - typedef boost::container::flat_map Graph_map; - typedef boost::container::flat_map Inv_graph_map; - - /* \brief Verifies if the simplices formed by vertices given by link_vertices - * form a pseudomanifold. - * The idea is to make a bipartite graph, where vertices are the d- and (d-1)-dimensional - * faces and edges represent adjacency between them. - */ - bool link_is_pseudomanifold(std::vector< Vertex_handle >& star_vertices, - int dimension) - { - Adj_graph adj_graph; - Graph_map d_map, f_map; // d_map = map for d-dimensional simplices - // f_map = map for its facets - typeVectorVertex init_vector = {}; - add_vertices_to_link_graph(star_vertices, - star_vertices.begin()+1, - adj_graph, - d_map, - f_map, - init_vector, - 0, dimension); - //std::cout << "DMAP_SIZE: " << d_map.size() << "\n"; - //std::cout << "FMAP_SIZE: " << f_map.size() << "\n"; - add_edges_to_link_graph(adj_graph, d_map, f_map); - for (auto f_map_it : f_map) - { - //std::cout << "Degree of " << f_map_it.first->first << " is " << boost::out_degree(f_map_it.second, adj_graph) << "\n"; - if (boost::out_degree(f_map_it.second, adj_graph) != 2) - { - /* - if (boost::out_degree(f_map_it.second, adj_graph) >= 3) - { - std::cout << "This simplex has 3+ cofaces: "; - for(auto v : simplex_vertex_range(f_map_it.first)) - std::cout << v << " "; - std::cout << std::endl; - Adj_it ai, ai_end; - for (std::tie(ai, ai_end) = boost::adjacent_vertices(f_map_it.second, adj_graph); ai != ai_end; ++ai) - { - - } - } - */ - count_bad[dimension]++; - return false; - } - } - // At this point I know that all (d-1)-simplices are adjacent to exactly 2 d-simplices - // What is left is to check the connexity - //std::vector components(boost::num_vertices(adj_graph)); - return true; //Forget the connexity - //return (boost::connected_components(adj_graph, &components[0]) == 1); - } - - public: -bool complex_is_pseudomanifold(int dimension) - { - Adj_graph adj_graph; - Graph_map d_map, f_map; // d_map = map for d-dimensional simplices - // f_map = map for its facets - Inv_graph_map inv_d_map; - typeVectorVertex init_vector = {}; - std::vector star_vertices; - for (int v: complex_vertex_range()) - star_vertices.push_back(v); - add_max_simplices_to_graph(star_vertices, - star_vertices.begin(), - adj_graph, - d_map, - f_map, - inv_d_map, - init_vector, - 0, dimension); - std::cout << "DMAP_SIZE: " << d_map.size() << "\n"; - std::cout << "FMAP_SIZE: " << f_map.size() << "\n"; - add_edges_to_link_graph(adj_graph, d_map, f_map); - for (auto f_map_it : f_map) - { - //std::cout << "Degree of " << f_map_it.first->first << " is " << boost::out_degree(f_map_it.second, adj_graph) << "\n"; - if (boost::out_degree(f_map_it.second, adj_graph) != 2) - { - if (boost::out_degree(f_map_it.second, adj_graph) >= 3) - { - std::cout << "This simplex has 3+ cofaces: "; - for(auto v : simplex_vertex_range(f_map_it.first)) - std::cout << v << " "; - std::cout << std::endl; - Adj_it ai, ai_end; - for (std::tie(ai, ai_end) = boost::adjacent_vertices(f_map_it.second, adj_graph); ai != ai_end; ++ai) - { - auto it = inv_d_map.find(*ai); - assert (it != inv_d_map.end()); - Simplex_handle sh = it->second; - for(auto v : simplex_vertex_range(sh)) - std::cout << v << " "; - std::cout << std::endl; - } - } - count_bad[dimension]++; - return false; - } - } - // At this point I know that all (d-1)-simplices are adjacent to exactly 2 d-simplices - // What is left is to check the connexity - //std::vector components(boost::num_vertices(adj_graph)); - return true; //Forget the connexity - //return (boost::connected_components(adj_graph, &components[0]) == 1); - } - private: - void add_vertices_to_link_graph(typeVectorVertex& star_vertices, - typename typeVectorVertex::iterator curr_v, - Adj_graph& adj_graph, - Graph_map& d_map, - Graph_map& f_map, - typeVectorVertex& curr_simplex, - int curr_d, - int link_dimension) - { - Simplex_handle sh; - Vertex_t vert; - typename typeVectorVertex::iterator it; - //std::pair resPair; - //typename Graph_map::iterator resPair; - //Add vertices - //std::cout << "Entered add vertices\n"; - for (it = curr_v; it != star_vertices.end(); ++it) - { - curr_simplex.push_back(*it); //push next vertex in question - curr_simplex.push_back(star_vertices[0]); //push the center of the star - /* - std::cout << "Searching for "; - print_vector(curr_simplex); - std::cout << " curr_dim " << curr_d << " d " << dimension << ""; - */ - typeVectorVertex curr_simplex_copy(curr_simplex); - sh = find(curr_simplex_copy); //a simplex of the star - curr_simplex.pop_back(); //pop the center of the star - curr_simplex_copy = typeVectorVertex(curr_simplex); - if (sh != null_simplex()) - { - //std::cout << " added\n"; - if (curr_d == link_dimension) - { - sh = find(curr_simplex_copy); //a simplex of the link - assert(sh != null_simplex()); //ASSERT! - vert = boost::add_vertex(adj_graph); - d_map.emplace(sh,vert); - } - else - { - - if (curr_d == link_dimension-1) - { - sh = find(curr_simplex_copy); //a simplex of the link - assert(sh != null_simplex()); - vert = boost::add_vertex(adj_graph); - f_map.emplace(sh,vert); - } - - //delete (&curr_simplex_copy); //Just so it doesn't stack - add_vertices_to_link_graph(star_vertices, - it+1, - adj_graph, - d_map, - f_map, - curr_simplex, - curr_d+1, link_dimension); - } - } - /* - else - std::cout << "\n"; - */ - curr_simplex.pop_back(); //pop the vertex in question - } - } - void add_edges_to_link_graph(Adj_graph& adj_graph, - Graph_map& d_map, - Graph_map& f_map) - { - Simplex_handle sh; - // Add edges - //std::cout << "Entered add edges:\n"; - typename Graph_map::iterator map_it; - for (auto d_map_pair : d_map) - { - //std::cout << "*"; - sh = d_map_pair.first; - Vertex_t d_vert = d_map_pair.second; - for (auto facet_sh : boundary_simplex_range(sh)) - //for (auto f_map_it : f_map) - { - //std::cout << "'"; - map_it = f_map.find(facet_sh); - //We must have all the facets in the graph at this point - assert(map_it != f_map.end()); - Vertex_t f_vert = map_it->second; - //std::cout << "Added edge " << sh->first << "-" << map_it->first->first << "\n"; - boost::add_edge(d_vert,f_vert,adj_graph); - } - } - } - - void add_max_simplices_to_graph(typeVectorVertex& star_vertices, - typename typeVectorVertex::iterator curr_v, - Adj_graph& adj_graph, - Graph_map& d_map, - Graph_map& f_map, - Inv_graph_map& inv_d_map, - typeVectorVertex& curr_simplex, - int curr_d, - int link_dimension) - { - Simplex_handle sh; - Vertex_t vert; - typename typeVectorVertex::iterator it; - //std::pair resPair; - //typename Graph_map::iterator resPair; - //Add vertices - //std::cout << "Entered add vertices\n"; - for (it = curr_v; it != star_vertices.end(); ++it) - { - curr_simplex.push_back(*it); //push next vertex in question - //curr_simplex.push_back(star_vertices[0]); //push the center of the star - /* - std::cout << "Searching for "; - print_vector(curr_simplex); - std::cout << " curr_dim " << curr_d << " d " << dimension << ""; - */ - typeVectorVertex curr_simplex_copy(curr_simplex); - sh = find(curr_simplex_copy); //a simplex of the star - //curr_simplex.pop_back(); //pop the center of the star - curr_simplex_copy = typeVectorVertex(curr_simplex); - if (sh != null_simplex()) - { - //std::cout << " added\n"; - if (curr_d == link_dimension) - { - sh = find(curr_simplex_copy); //a simplex of the link - assert(sh != null_simplex()); //ASSERT! - vert = boost::add_vertex(adj_graph); - d_map.emplace(sh,vert); - inv_d_map.emplace(vert,sh); - } - else - { - - if (curr_d == link_dimension-1) - { - sh = find(curr_simplex_copy); //a simplex of the link - assert(sh != null_simplex()); - vert = boost::add_vertex(adj_graph); - f_map.emplace(sh,vert); - } - - //delete (&curr_simplex_copy); //Just so it doesn't stack - add_max_simplices_to_graph(star_vertices, - it+1, - adj_graph, - d_map, - f_map, - inv_d_map, - curr_simplex, - curr_d+1, link_dimension); - } - } - /* - else - std::cout << "\n"; - */ - curr_simplex.pop_back(); //pop the vertex in question - } - } - public: /** \brief Verification if every simplex in the complex is witnessed */ -- cgit v1.2.3