summaryrefslogtreecommitdiff
path: root/src/Toplex_map/include/gudhi/Toplex_map.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toplex_map/include/gudhi/Toplex_map.h')
-rw-r--r--src/Toplex_map/include/gudhi/Toplex_map.h143
1 files changed, 77 insertions, 66 deletions
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<Toplex_map::Vertex> Simplex;
-
- /** The type of the pointers to maximal simplices. */
- typedef std::shared_ptr<Toplex_map::Simplex> 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<Toplex_map::Simplex_ptr, Sptr_hash, Sptr_equal> Simplex_ptr_set;
-
- /** \brief Adds the given simplex to the complex.
- * Nothing happens if the simplex has a coface in the complex. */
- template <typename Input_vertex_range>
- 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 <typename Input_vertex_range>
- void remove_simplex(const Input_vertex_range &vertex_range);
-
- /** Does a simplex belong to the complex ? */
- template <typename Input_vertex_range>
- bool membership(const Input_vertex_range &vertex_range) const;
-
- /** Does a simplex is a toplex ? */
- template <typename Input_vertex_range>
- 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 <typename Input_vertex_range>
- 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 <typename Input_vertex_range>
- 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<Toplex_map::Vertex>;
+
+ /** The type of the pointers to maximal simplices. */
+ using Simplex_ptr = std::shared_ptr<Toplex_map::Simplex>;
+
+ 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<Toplex_map::Simplex_ptr, Sptr_hash, Sptr_equal>;
+
+ /** \brief Adds the given simplex to the complex.
+ * Nothing happens if the simplex has a coface in the complex. */
+ template <typename Input_vertex_range>
+ 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 <typename Input_vertex_range>
+ void remove_simplex(const Input_vertex_range &vertex_range);
+
+ /** Does a simplex belong to the complex ? */
+ template <typename Input_vertex_range>
+ bool membership(const Input_vertex_range &vertex_range) const;
+
+ /** Does a simplex is a toplex ? */
+ template <typename Input_vertex_range>
+ 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 <typename Input_vertex_range>
+ 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<Toplex_map::Vertex> 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 <typename Input_vertex_range>
+ void insert_independent_simplex(const Input_vertex_range &vertex_range);
+
protected:
- /** \internal Gives an index in order to look for a simplex quickly. */
- template <typename Input_vertex_range>
- Toplex_map::Vertex best_index(const Input_vertex_range &vertex_range) const;
-
- /** \internal The map from vertices to toplices */
- std::unordered_map<Toplex_map::Vertex, Toplex_map::Simplex_ptr_set> t0;
-
- const Toplex_map::Vertex vertex_upper_bound = std::numeric_limits<Toplex_map::Vertex>::max();
+ /** \internal Gives an index in order to look for a simplex quickly. */
+ template <typename Input_vertex_range>
+ Toplex_map::Vertex best_index(const Input_vertex_range &vertex_range) const;
+
+ /** \internal The map from vertices to toplices */
+ std::unordered_map<Toplex_map::Vertex, Toplex_map::Simplex_ptr_set> t0;
+
+ const Toplex_map::Vertex vertex_upper_bound = std::numeric_limits<Toplex_map::Vertex>::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)