From da1d57f361de13f48d606eda427e63c700574f74 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 15 Oct 2018 20:39:12 +0000 Subject: Toplex_map indentation simple toplex map example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3953 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 253f001adf27dbe8318ae12996f32b07e4fab139 --- src/Toplex_map/include/gudhi/Toplex_map.h | 143 ++++++++++++++++-------------- 1 file changed, 77 insertions(+), 66 deletions(-) (limited to 'src/Toplex_map/include') diff --git a/src/Toplex_map/include/gudhi/Toplex_map.h b/src/Toplex_map/include/gudhi/Toplex_map.h index 565415e1..7cde8ea1 100644 --- a/src/Toplex_map/include/gudhi/Toplex_map.h +++ b/src/Toplex_map/include/gudhi/Toplex_map.h @@ -17,79 +17,94 @@ class Toplex_map { public: - /** Vertex is the type of vertices. */ - typedef std::size_t Vertex; - - /** Simplex is the type of simplices. */ - typedef std::set Simplex; - - /** The type of the pointers to maximal simplices. */ - typedef std::shared_ptr Simplex_ptr; - - struct Sptr_hash{ std::size_t operator()(const Toplex_map::Simplex_ptr& s) const; }; - struct Sptr_equal{ std::size_t operator()(const Toplex_map::Simplex_ptr& a, const Toplex_map::Simplex_ptr& b) const; }; - /** The type of the sets of Toplex_map::Simplex_ptr. */ - typedef std::unordered_set Simplex_ptr_set; - - /** \brief Adds the given simplex to the complex. - * Nothing happens if the simplex has a coface in the complex. */ - template - void insert_simplex(const Input_vertex_range &vertex_range); - - /** \brief Removes the given simplex and its cofaces from the complex. - * Its faces are kept inside. */ - template - void remove_simplex(const Input_vertex_range &vertex_range); - - /** Does a simplex belong to the complex ? */ - template - bool membership(const Input_vertex_range &vertex_range) const; - - /** Does a simplex is a toplex ? */ - template - bool maximality(const Input_vertex_range &vertex_range) const; - - /** Gives a set of pointers to the maximal cofaces of a simplex. - * Gives all the toplices if given the empty simplex. - * Gives not more than max_number maximal cofaces if max_number is strictly positive. */ - template - Toplex_map::Simplex_ptr_set maximal_cofaces(const Input_vertex_range &vertex_range, const std::size_t max_number = 0) const; - - /** Contracts one edge in the complex. - * The edge has to verify the link condition if you want to preserve topology. - * Returns the remaining vertex. */ - Toplex_map::Vertex contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y); - - /** Adds the given simplex to the complex. - * The simplex must not have neither maximal face nor coface in the complex. */ - template - void insert_independent_simplex(const Input_vertex_range &vertex_range); + /** Vertex is the type of vertices. */ + using Vertex = std::size_t; + + /** Simplex is the type of simplices. */ + using Simplex = std::set; + + /** The type of the pointers to maximal simplices. */ + using Simplex_ptr = std::shared_ptr; + + struct Sptr_hash { + std::size_t operator()(const Toplex_map::Simplex_ptr& s) const; + }; + + struct Sptr_equal{ + std::size_t operator()(const Toplex_map::Simplex_ptr& a, const Toplex_map::Simplex_ptr& b) const; + }; + + /** The type of the sets of Toplex_map::Simplex_ptr. */ + using Simplex_ptr_set = std::unordered_set; + + /** \brief Adds the given simplex to the complex. + * Nothing happens if the simplex has a coface in the complex. */ + template + void insert_simplex(const Input_vertex_range &vertex_range); + + /** \brief Removes the given simplex and its cofaces from the complex. + * Its faces are kept inside. */ + template + void remove_simplex(const Input_vertex_range &vertex_range); + + /** Does a simplex belong to the complex ? */ + template + bool membership(const Input_vertex_range &vertex_range) const; + + /** Does a simplex is a toplex ? */ + template + bool maximality(const Input_vertex_range &vertex_range) const; + + /** Gives a set of pointers to the maximal cofaces of a simplex. + * Gives all the toplices if given the empty simplex. + * Gives not more than max_number maximal cofaces if max_number is strictly positive. */ + template + Toplex_map::Simplex_ptr_set maximal_cofaces(const Input_vertex_range &vertex_range, const std::size_t max_number = 0) const; + + /** Gives a set of pointers to the maximal simplices. + * Gives not more than max_number maximal cofaces if max_number is strictly positive. */ + Toplex_map::Simplex_ptr_set maximal_simplices(const std::size_t max_number = 0) const { + return maximal_cofaces(Simplex(), max_number); + } - /** \internal Removes a toplex without adding facets after. */ - void erase_maximal(const Toplex_map::Simplex_ptr& sptr); + /** Contracts one edge in the complex. + * The edge has to verify the link condition if you want to preserve topology. + * Returns the remaining vertex. */ + Toplex_map::Vertex contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y); - /** Removes a vertex from any simplex containing it. */ - void remove_vertex(const Toplex_map::Vertex x); + /** Removes a vertex from any simplex containing it. */ + void remove_vertex(const Toplex_map::Vertex x); - /** \brief Number of maximal simplices. */ - std::size_t num_maximal_simplices() const; + /** \brief Number of maximal simplices. */ + std::size_t num_maximal_simplices() const { + return maximal_simplices().size(); + } /** \brief Number of vertices. */ - std::size_t num_vertices() const{ + std::size_t num_vertices() const { return t0.size(); } std::set unitary_collapse(const Toplex_map::Vertex k, const Toplex_map::Vertex d); + /** Adds the given simplex to the complex. + * The simplex must not have neither maximal face nor coface in the complex. */ + template + void insert_independent_simplex(const Input_vertex_range &vertex_range); + protected: - /** \internal Gives an index in order to look for a simplex quickly. */ - template - Toplex_map::Vertex best_index(const Input_vertex_range &vertex_range) const; - - /** \internal The map from vertices to toplices */ - std::unordered_map t0; - - const Toplex_map::Vertex vertex_upper_bound = std::numeric_limits::max(); + /** \internal Gives an index in order to look for a simplex quickly. */ + template + Toplex_map::Vertex best_index(const Input_vertex_range &vertex_range) const; + + /** \internal The map from vertices to toplices */ + std::unordered_map t0; + + const Toplex_map::Vertex vertex_upper_bound = std::numeric_limits::max(); + + /** \internal Removes a toplex without adding facets after. */ + void erase_maximal(const Toplex_map::Simplex_ptr& sptr); + }; // Pointers are also used as key in the hash sets. @@ -240,10 +255,6 @@ void Toplex_map::remove_vertex(const Toplex_map::Vertex x){ } } -std::size_t Toplex_map::num_maximal_simplices() const{ - return maximal_cofaces(Simplex()).size(); -} - inline void Toplex_map::erase_maximal(const Toplex_map::Simplex_ptr& sptr){ Simplex sigma(*sptr); if (sptr->size()==0) -- cgit v1.2.3