16 #include <unordered_set>    17 #include <unordered_map>    49   using Simplex_ptr_set = std::unordered_set<Toplex_map::Simplex_ptr, Sptr_hash, Sptr_equal>;
    53   template <
typename Input_vertex_range>
    58   template <
typename Input_vertex_range>
    62   template <
typename Input_vertex_range>
    63   bool membership(
const Input_vertex_range& vertex_range) 
const;
    66   template <
typename Input_vertex_range>
    67   bool maximality(
const Input_vertex_range& vertex_range) 
const;
    72   template <
typename Input_vertex_range>
    74                                               const std::size_t max_number = 0) 
const;
    96   std::set<Vertex> unitary_collapse(
const Vertex k, 
const Vertex d);
   100   template <
typename Input_vertex_range>
   105   template <
typename Input_vertex_range>
   106   Vertex best_index(
const Input_vertex_range& vertex_range) 
const;
   109   std::unordered_map<Vertex, Toplex_map::Simplex_ptr_set> t0;
   111   const Vertex VERTEX_UPPER_BOUND = std::numeric_limits<Vertex>::max();
   118 template <
typename Input_vertex_range>
   122 template <
typename Input_vertex_range1, 
typename Input_vertex_range2>
   123 bool included(
const Input_vertex_range1& vertex_range1, 
const Input_vertex_range2& vertex_range2);
   126 template <
typename Input_vertex_range>
   127 std::vector<Toplex_map::Simplex> facets(
const Input_vertex_range& vertex_range);
   129 template <
typename Input_vertex_range>
   132   bool replace_facets = 
true;
   135       replace_facets = 
false;
   139     for (
const Toplex_map::Simplex& facet : facets(vertex_range)) erase_maximal(get_key(facet));
   141     for (
const Vertex& v : vertex_range)
   145           if (included(*fptr, vertex_range)) erase_maximal(fptr);
   150 template <
typename Input_vertex_range>
   152   if (vertex_range.begin() == vertex_range.end()) t0.clear();
   155     const Vertex& v = best_index(vertex_range);
   159         if (included(vertex_range, *sptr)) {
   168 template <
typename Input_vertex_range>
   170   if (t0.size() == 0) 
return false;
   171   const Vertex& v = best_index(vertex_range);
   172   if (!t0.count(v)) 
return false;
   175     if (included(vertex_range, *sptr)) 
return true;
   179 template <
typename Input_vertex_range>
   181   const Vertex& v = best_index(vertex_range);
   182   if (!t0.count(v)) 
return false;
   183   return t0.at(v).count(get_key(vertex_range));
   186 template <
typename Input_vertex_range>
   188                                                         const std::size_t max_number)
 const {
   191     cofaces.emplace(get_key(vertex_range));
   192   else if (vertex_range.begin() == vertex_range.end())
   193     for (
const auto& kv : t0)
   196         cofaces.emplace(sptr);
   197         if (cofaces.size() == max_number) 
return cofaces;
   200     const Vertex& v = best_index(vertex_range);
   203         if (included(vertex_range, *sptr)) {
   204           cofaces.emplace(sptr);
   205           if (cofaces.size() == max_number) 
return cofaces;
   212   if (!t0.count(x)) 
return y;
   213   if (!t0.count(y)) 
return x;
   215   if (t0.at(x).size() > t0.at(y).size())
   237     for (
const Vertex v : sigma) r.insert(v);
   244 template <
typename Input_vertex_range>
   246   auto key = get_key(vertex_range);
   247   for (
const Vertex& v : vertex_range) {
   249     t0.at(v).emplace(key);
   264   if (sptr->size() == 0) sigma.insert(VERTEX_UPPER_BOUND);
   265   for (
const Vertex& v : sigma) {
   266     t0.at(v).erase(sptr);
   267     if (t0.at(v).size() == 0) t0.erase(v);
   271 template <
typename Input_vertex_range>
   272 Toplex_map::Vertex Toplex_map::best_index(
const Input_vertex_range& vertex_range)
 const {
   273   std::size_t min = std::numeric_limits<size_t>::max();
   274   Vertex arg_min = VERTEX_UPPER_BOUND;
   275   for (
const Vertex& v : vertex_range)
   278     else if (t0.at(v).size() < min)
   279       min = t0.at(v).size(), arg_min = v;
   285   if (s1->size() != s2->size()) 
return false;
   286   return included(*s1, *s2);
   291   std::hash<double> h_f;
   294   for (
const Vertex& v : *s) h += h_f(static_cast<double>(v));
   298 template <
typename Input_vertex_range>
   301   return std::make_shared<Toplex_map::Simplex>(s);
   304 template <
typename Input_vertex_range1, 
typename Input_vertex_range2>
   305 bool included(
const Input_vertex_range1& vertex_range1, 
const Input_vertex_range2& vertex_range2) {
   308     if (!s2.count(v)) 
return false;
   312 template <
typename Input_vertex_range>
   313 std::vector<Toplex_map::Simplex> facets(
const Input_vertex_range& vertex_range) {
   314   std::vector<Toplex_map::Simplex> facets;
   318     facets.emplace_back(f);
 std::unordered_set< Toplex_map::Simplex_ptr, Sptr_hash, Sptr_equal > Simplex_ptr_set
Definition: Toplex_map.h:49
void remove_vertex(const Vertex x)
Definition: Toplex_map.h:253
Definition: SimplicialComplexForAlpha.h:14
std::shared_ptr< Toplex_map::Simplex > Simplex_ptr
Definition: Toplex_map.h:38
void insert_independent_simplex(const Input_vertex_range &vertex_range)
Definition: Toplex_map.h:245
bool membership(const Input_vertex_range &vertex_range) const
Definition: Toplex_map.h:169
Vertex contraction(const Vertex x, const Vertex y)
Definition: Toplex_map.h:211
std::size_t Vertex
Definition: Toplex_map.h:32
Toplex_map::Simplex_ptr_set maximal_cofaces(const Input_vertex_range &vertex_range, const std::size_t max_number=0) const
Definition: Toplex_map.h:187
void remove_simplex(const Input_vertex_range &vertex_range)
Removes the given simplex and its cofaces from the complex. Its faces are kept inside. 
Definition: Toplex_map.h:151
std::set< Vertex > Simplex
Definition: Toplex_map.h:35
std::size_t num_vertices() const
Number of vertices. 
Definition: Toplex_map.h:94
void insert_simplex(const Input_vertex_range &vertex_range)
Adds the given simplex to the complex. Nothing happens if the simplex is already in the complex (i...
Definition: Toplex_map.h:130
std::size_t num_maximal_simplices() const
Number of maximal simplices. 
Definition: Toplex_map.h:91
bool maximality(const Input_vertex_range &vertex_range) const
Definition: Toplex_map.h:180
Toplex map data structure for representing unfiltered simplicial complexes. 
Definition: Toplex_map.h:29
Toplex_map::Simplex_ptr_set maximal_simplices(const std::size_t max_number=0) const
Definition: Toplex_map.h:78