Gudhi  1.1.0
 All Classes Functions Typedefs Friends Groups Pages
Simplex_tree.h
1 /* This file is part of the Gudhi Library. The Gudhi library
2  * (Geometric Understanding in Higher Dimensions) is a generic C++
3  * library for computational topology.
4  *
5  * Author(s): Clément Maria
6  *
7  * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
24 #define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
25 
26 #include <gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h>
27 #include <gudhi/Simplex_tree/Simplex_tree_siblings.h>
28 #include <gudhi/Simplex_tree/Simplex_tree_iterators.h>
29 #include <gudhi/Simplex_tree/indexing_tag.h>
30 
31 #include <boost/container/flat_map.hpp>
32 #include <boost/iterator/transform_iterator.hpp>
33 #include <boost/graph/adjacency_list.hpp>
34 
35 #include <algorithm>
36 #include <utility>
37 #include <vector>
38 
39 namespace Gudhi {
40 
86 template<typename IndexingTag = linear_indexing_tag,
87  typename FiltrationValue = double, typename SimplexKey = int // must be a signed integer type
88  , typename VertexHandle = int // must be a signed integer type, int convertible to it
89 // , bool ContiguousVertexHandles = true //true is Vertex_handles are exactly the set [0;n)
90 >
91 class Simplex_tree {
92  public:
93  typedef IndexingTag Indexing_tag;
106 
107  /* Type of node in the simplex tree. */
108  typedef Simplex_tree_node_explicit_storage<Simplex_tree> Node;
109  /* Type of dictionary Vertex_handle -> Node for traversing the simplex tree. */
110  typedef typename boost::container::flat_map<Vertex_handle, Node> Dictionary;
111 
112  friend class Simplex_tree_node_explicit_storage< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
113  friend class Simplex_tree_siblings< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle>, Dictionary>;
114  friend class Simplex_tree_simplex_vertex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
115  friend class Simplex_tree_boundary_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
116  friend class Simplex_tree_complex_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
117  friend class Simplex_tree_skeleton_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
118 
119  /* \brief Set of nodes sharing a same parent in the simplex tree. */
120  /* \brief Set of nodes sharing a same parent in the simplex tree. */
121  typedef Simplex_tree_siblings<Simplex_tree, Dictionary> Siblings;
122 
123  public:
126  typedef typename Dictionary::iterator Simplex_handle;
127 
128  private:
129  typedef typename Dictionary::iterator Dictionary_it;
130  typedef typename Dictionary_it::value_type Dit_value_t;
131 
132  struct return_first {
133  Vertex_handle operator()(const Dit_value_t& p_sh) const {
134  return p_sh.first;
135  }
136  };
137 
138  public:
150  typedef boost::transform_iterator<return_first, Dictionary_it> Complex_vertex_iterator;
152  typedef boost::iterator_range<Complex_vertex_iterator> Complex_vertex_range;
156  typedef Simplex_tree_simplex_vertex_iterator<Simplex_tree> Simplex_vertex_iterator;
158  typedef boost::iterator_range<Simplex_vertex_iterator> Simplex_vertex_range;
162  typedef Simplex_tree_boundary_simplex_iterator<Simplex_tree> Boundary_simplex_iterator;
164  typedef boost::iterator_range<Boundary_simplex_iterator> Boundary_simplex_range;
168  typedef Simplex_tree_complex_simplex_iterator<Simplex_tree> Complex_simplex_iterator;
170  typedef boost::iterator_range<Complex_simplex_iterator> Complex_simplex_range;
175  typedef Simplex_tree_skeleton_simplex_iterator<Simplex_tree> Skeleton_simplex_iterator;
178  typedef boost::iterator_range<Skeleton_simplex_iterator> Skeleton_simplex_range;
182  typedef typename std::vector<Simplex_handle>::iterator Filtration_simplex_iterator;
184  typedef boost::iterator_range<Filtration_simplex_iterator> Filtration_simplex_range;
185 
186  /* @} */ // end name range and iterator types
194  return Complex_vertex_range(
195  boost::make_transform_iterator(root_.members_.begin(), return_first()),
196  boost::make_transform_iterator(root_.members_.end(), return_first()));
197  }
198 
207  }
208 
221  }
222 
238  if (filtration_vect_.empty()) {
240  }
241  return Filtration_simplex_range(filtration_vect_.begin(),
242  filtration_vect_.end());
243  }
244 
245  Filtration_simplex_range filtration_simplex_range() {
246  return filtration_simplex_range(Indexing_tag());
247  }
257  }
258 
276  }
277  // end range and iterator methods
284  : null_vertex_(-1),
285  threshold_(0),
286  num_simplices_(0),
287  root_(NULL, null_vertex_),
288  filtration_vect_(),
289  dimension_(-1) {
290  }
291 
294  for (auto sh = root_.members().begin(); sh != root_.members().end(); ++sh) {
295  if (has_children(sh)) {
296  rec_delete(sh->second.children());
297  }
298  }
299  } // end constructor/destructor
301  private:
303  void rec_delete(Siblings * sib) {
304  for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) {
305  if (has_children(sh)) {
306  rec_delete(sh->second.children());
307  }
308  }
309  delete sib;
310  }
311 
312  public:
317  return sh->second.key();
318  }
323  return filtration_vect_[key];
324  }
329  if (sh != null_simplex()) {
330  return sh->second.filtration();
331  } else {
332  return INFINITY;
333  } // filtration(); }
334  }
337  return threshold_;
338  }
344  return Dictionary_it(NULL);
345  }
349  return -1;
350  }
354  return null_vertex_;
355  }
357  size_t num_vertices() {
358  return root_.members_.size();
359  }
363  const unsigned int& num_simplices() const {
364  return num_simplices_;
365  }
366 
371  Siblings * curr_sib = self_siblings(sh);
372  int dim = 0;
373  while (curr_sib != NULL) {
374  ++dim;
375  curr_sib = curr_sib->oncles();
376  }
377  return dim - 1;
378  }
380  int dimension() {
381  return dimension_;
382  }
383 
387  return (sh->second.children()->parent() == sh->first);
388  }
389 
398  template<class RandomAccessVertexRange>
399  Simplex_handle find(const RandomAccessVertexRange & s) {
400  if (s.begin() == s.end())
401  std::cerr << "Empty simplex \n";
402 
403  sort(s.begin(), s.end());
404 
405  Siblings * tmp_sib = &root_;
406  Dictionary_it tmp_dit;
407  Vertex_handle last = s[s.size() - 1];
408  for (auto v : s) {
409  tmp_dit = tmp_sib->members_.find(v);
410  if (tmp_dit == tmp_sib->members_.end()) {
411  return null_simplex();
412  }
413  if (!has_children(tmp_dit) && v != last) {
414  return null_simplex();
415  }
416  tmp_sib = tmp_dit->second.children();
417  }
418  return tmp_dit;
419  }
420 
424  return root_.members_.begin() + v;
425  }
426 //{ return root_.members_.find(v); }
427 
451  template<class RandomAccessVertexRange>
452  std::pair<Simplex_handle, bool> insert(RandomAccessVertexRange & simplex,
454  if (simplex.empty()) {
455  return std::pair<Simplex_handle, bool>(null_simplex(), true);
456  }
457 
458  sort(simplex.begin(), simplex.end()); // must be sorted in increasing order
459 
460  Siblings * curr_sib = &root_;
461  std::pair<Simplex_handle, bool> res_insert;
462  typename RandomAccessVertexRange::iterator vi;
463  for (vi = simplex.begin(); vi != simplex.end() - 1; ++vi) {
464  res_insert = curr_sib->members_.emplace(*vi, Node(curr_sib, filtration));
465  if (!(has_children(res_insert.first))) {
466  res_insert.first->second.assign_children(new Siblings(curr_sib, *vi));
467  }
468  curr_sib = res_insert.first->second.children();
469  }
470  res_insert = curr_sib->members_.emplace(*vi, Node(curr_sib, filtration));
471  if (!res_insert.second) { // if already in the complex
472  if (res_insert.first->second.filtration() > filtration) { // if filtration value modified
473  res_insert.first->second.assign_filtration(filtration);
474  return res_insert;
475  }
476  return std::pair<Simplex_handle, bool>(null_simplex(), false); // if filtration value unchanged
477  }
478  // otherwise the insertion has succeeded
479  return res_insert;
480  }
481 
485  sh->second.assign_key(key);
486  }
487 
488  public:
492  std::pair<Simplex_handle, Simplex_handle> endpoints(Simplex_handle sh) {
493  return std::pair<Simplex_handle, Simplex_handle>(
494  root_.members_.find(sh->first),
495  root_.members_.find(self_siblings(sh)->parent()));
496  }
497 
499  Siblings * self_siblings(Simplex_handle sh) {
500  if (sh->second.children()->parent() == sh->first)
501  return sh->second.children()->oncles();
502  else
503  return sh->second.children();
504  }
505 
506 // void display_simplex(Simplex_handle sh)
507 // {
508 // std::cout << " " << "[" << filtration(sh) << "] ";
509 // for( auto vertex : simplex_vertex_range(sh) )
510 // { std::cout << vertex << " "; }
511 // }
512 
513  // void print(Simplex_handle sh, std::ostream& os = std::cout)
514  // { for(auto v : simplex_vertex_range(sh)) {os << v << " ";}
515  // os << std::endl; }
516 
517  public:
519  Siblings * root() {
520  return &root_;
521  }
522 
523  public:
526  threshold_ = fil;
527  }
529  void set_num_simplices(const unsigned int& num_simplices) {
530  num_simplices_ = num_simplices;
531  }
534  dimension_ = dimension;
535  }
536 
537  public:
554  filtration_vect_.clear();
555  filtration_vect_.reserve(num_simplices());
556  for (auto cpx_it = complex_simplex_range().begin();
557  cpx_it != complex_simplex_range().end(); ++cpx_it) {
558  filtration_vect_.push_back(*cpx_it);
559  }
560 
561  // the stable sort ensures the ordering heuristic
562  std::stable_sort(filtration_vect_.begin(), filtration_vect_.end(),
563  is_before_in_filtration(this));
564  }
565 
566  private:
574  bool reverse_lexicographic_order(Simplex_handle sh1, Simplex_handle sh2) {
577  Simplex_vertex_iterator it1 = rg1.begin();
578  Simplex_vertex_iterator it2 = rg2.begin();
579  while (it1 != rg1.end() && it2 != rg2.end()) {
580  if (*it1 == *it2) {
581  ++it1;
582  ++it2;
583  } else {
584  return *it1 < *it2;
585  }
586  }
587  return ((it1 == rg1.end()) && (it2 != rg2.end()));
588  }
595  struct is_before_in_filtration {
596  explicit is_before_in_filtration(Simplex_tree * st)
597  : st_(st) {
598  }
599 
600  bool operator()(const Simplex_handle sh1, const Simplex_handle sh2) const {
601  if (st_->filtration(sh1) != st_->filtration(sh2)) {
602  return st_->filtration(sh1) < st_->filtration(sh2);
603  }
604 
605  return st_->reverse_lexicographic_order(sh1, sh2); // is sh1 a proper subface of sh2
606  }
607 
608  Simplex_tree * st_;
609  };
610 
611  public:
630  template<class OneSkeletonGraph>
631  void insert_graph(const OneSkeletonGraph& skel_graph) {
632  assert(num_simplices() == 0); // the simplex tree must be empty
633 
634  if (boost::num_vertices(skel_graph) == 0) {
635  return;
636  }
637  if (num_edges(skel_graph) == 0) {
638  dimension_ = 0;
639  } else {
640  dimension_ = 1;
641  }
642 
643  num_simplices_ = boost::num_vertices(skel_graph)
644  + boost::num_edges(skel_graph);
645  root_.members_.reserve(boost::num_vertices(skel_graph));
646 
647  typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator v_it,
648  v_it_end;
649  for (tie(v_it, v_it_end) = boost::vertices(skel_graph); v_it != v_it_end;
650  ++v_it) {
651  root_.members_.emplace_hint(
652  root_.members_.end(), *v_it,
653  Node(&root_, boost::get(vertex_filtration_t(), skel_graph, *v_it)));
654  }
655  typename boost::graph_traits<OneSkeletonGraph>::edge_iterator e_it,
656  e_it_end;
657  for (tie(e_it, e_it_end) = boost::edges(skel_graph); e_it != e_it_end;
658  ++e_it) {
659  auto u = source(*e_it, skel_graph);
660  auto v = target(*e_it, skel_graph);
661  if (u < v) { // count edges only once { std::swap(u,v); } // u < v
662  auto sh = find_vertex(u);
663  if (!has_children(sh)) {
664  sh->second.assign_children(new Siblings(&root_, sh->first));
665  }
666 
667  sh->second.children()->members().emplace(
668  v,
669  Node(sh->second.children(),
670  boost::get(edge_filtration_t(), skel_graph, *e_it)));
671  }
672  }
673  }
685  void expansion(int max_dim) {
686  dimension_ = max_dim;
687  for (Dictionary_it root_it = root_.members_.begin();
688  root_it != root_.members_.end(); ++root_it) {
689  if (has_children(root_it)) {
690  siblings_expansion(root_it->second.children(), max_dim - 1);
691  }
692  }
693  dimension_ = max_dim - dimension_;
694  }
695 
696  private:
698  void siblings_expansion(Siblings * siblings, // must contain elements
699  int k) {
700  if (dimension_ > k) {
701  dimension_ = k;
702  }
703  if (k == 0)
704  return;
705  Dictionary_it next = siblings->members().begin();
706  ++next;
707 
708  static std::vector<std::pair<Vertex_handle, Node> > inter; // static, not thread-safe.
709  for (Dictionary_it s_h = siblings->members().begin();
710  s_h != siblings->members().end(); ++s_h, ++next) {
711  Simplex_handle root_sh = find_vertex(s_h->first);
712  if (has_children(root_sh)) {
713  intersection(
714  inter, // output intersection
715  next, // begin
716  siblings->members().end(), // end
717  root_sh->second.children()->members().begin(),
718  root_sh->second.children()->members().end(),
719  s_h->second.filtration());
720  if (inter.size() != 0) {
721  this->num_simplices_ += inter.size();
722  Siblings * new_sib = new Siblings(siblings, // oncles
723  s_h->first, // parent
724  inter); // boost::container::ordered_unique_range_t
725  inter.clear();
726  s_h->second.assign_children(new_sib);
727  siblings_expansion(new_sib, k - 1);
728  } else {
729  s_h->second.assign_children(siblings); // ensure the children property
730  inter.clear();
731  }
732  }
733  }
734  }
737  void intersection(std::vector<std::pair<Vertex_handle, Node> >& intersection,
738  Dictionary_it begin1, Dictionary_it end1,
739  Dictionary_it begin2, Dictionary_it end2,
740  Filtration_value filtration) {
741  if (begin1 == end1 || begin2 == end2)
742  return; // ----->>
743  while (true) {
744  if (begin1->first == begin2->first) {
745  intersection.push_back(
746  std::pair<Vertex_handle, Node>(
747  begin1->first,
748  Node(NULL, maximum(begin1->second.filtration(), begin2->second.filtration(), filtration))));
749  ++begin1;
750  ++begin2;
751  if (begin1 == end1 || begin2 == end2)
752  return; // ----->>
753  } else {
754  if (begin1->first < begin2->first) {
755  ++begin1;
756  if (begin1 == end1)
757  return;
758  } else {
759  ++begin2;
760  if (begin2 == end2)
761  return; // ----->>
762  }
763  }
764  }
765  }
767  Filtration_value maximum(Filtration_value a, Filtration_value b,
768  Filtration_value c) {
769  Filtration_value max = (a < b) ? b : a;
770  return ((max < c) ? c : max);
771  }
772 
773  public:
780  void print_hasse(std::ostream& os) {
781  os << num_simplices() << " " << std::endl;
782  for (auto sh : filtration_simplex_range(Indexing_tag())) {
783  os << dimension(sh) << " ";
784  for (auto b_sh : boundary_simplex_range(sh)) {
785  os << key(b_sh) << " ";
786  }
787  os << filtration(sh) << " \n";
788  }
789  }
790 
791  private:
792  Vertex_handle null_vertex_;
794  Filtration_value threshold_;
796  unsigned int num_simplices_;
798  Siblings root_;
800  std::vector<Simplex_handle> filtration_vect_;
802  int dimension_;
803 };
804 
805 // Print a Simplex_tree in os.
806 template<typename T1, typename T2, typename T3>
807 std::ostream& operator<<(std::ostream & os, Simplex_tree<T1, T2, T3> & st) {
808  for (auto sh : st.filtration_simplex_range()) {
809  os << st.dimension(sh) << " ";
810  for (auto v : st.simplex_vertex_range(sh)) {
811  os << v << " ";
812  }
813  os << st.filtration(sh) << "\n"; // TODO(VR): why adding the key ?? not read ?? << " " << st.key(sh) << " \n";
814  }
815  return os;
816 }
817 template<typename T1, typename T2, typename T3>
818 std::istream& operator>>(std::istream & is, Simplex_tree<T1, T2, T3> & st) {
819  // assert(st.num_simplices() == 0);
820 
821  std::vector<typename Simplex_tree<T1, T2, T3>::Vertex_handle> simplex;
822  typename Simplex_tree<T1, T2, T3>::Filtration_value fil;
823  typename Simplex_tree<T1, T2, T3>::Filtration_value max_fil = 0;
824  int max_dim = -1;
825  size_t num_simplices = 0;
826  while (read_simplex(is, simplex, fil)) { // read all simplices in the file as a list of vertices
827  ++num_simplices;
828  int dim = static_cast<int>(simplex.size() - 1); // Warning : simplex_size needs to be casted in int - Can be 0
829  if (max_dim < dim) {
830  max_dim = dim;
831  }
832  if (max_fil < fil) {
833  max_fil = fil;
834  }
835  st.insert(simplex, fil); // insert every simplex in the simplex tree
836  simplex.clear();
837  }
838  st.set_num_simplices(num_simplices);
839  st.set_dimension(max_dim);
840  st.set_filtration(max_fil);
841 
842  return is;
843 }
844  // end defgroup simplex_tree
846 } // namespace Gudhi
847 
848 #endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
unspecified Simplex_key
Key associated to each simplex.
Definition: FilteredComplex.h:35
Simplex_handle null_simplex()
Returns a Simplex_handle different from all Simplex_handles associated to the simplices in the simpli...
Definition: Simplex_tree.h:343
SimplexKey Simplex_key
Key associated to each simplex.
Definition: Simplex_tree.h:101
Simplex_tree_skeleton_simplex_iterator< Simplex_tree > Skeleton_simplex_iterator
Iterator over the simplices of the skeleton of the simplicial complex, for a given dimension...
Definition: Simplex_tree.h:175
Complex_simplex_range complex_simplex_range()
Returns a range over the simplices of the simplicial complex.
Definition: Simplex_tree.h:204
Tag for a linear ordering of simplices.
Definition: indexing_tag.h:32
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:91
boost::transform_iterator< return_first, Dictionary_it > Complex_vertex_iterator
Iterator over the vertices of the simplicial complex.
Definition: Simplex_tree.h:150
Simplex_key null_key()
Returns a key different for all keys associated to the simplices of the simplicial complex...
Definition: Simplex_tree.h:348
Concept describing an indexing scheme (see FilteredComplex) for applying continuous maps to a cell co...
Definition: IndexingTag.h:30
~Simplex_tree()
Destructor; deallocates the whole tree structure.
Definition: Simplex_tree.h:293
void set_filtration(Filtration_value fil)
Definition: Simplex_tree.h:525
void assign_key(Simplex_handle sh, Simplex_key key)
Assign a value 'key' to the key of the simplex represented by the Simplex_handle 'sh'.
Definition: Simplex_tree.h:484
Simplex_handle simplex(Simplex_key key)
Returns the simplex associated to a key.
Definition: Simplex_tree.h:322
Simplex_key key(Simplex_handle sh)
Returns the key associated to a simplex.
Definition: Simplex_tree.h:316
Simplex_handle find(const RandomAccessVertexRange &s)
Given a range of Vertex_handles, returns the Simplex_handle of the simplex in the simplicial complex ...
Definition: Simplex_tree.h:399
Key type used as simplex identifier.
Definition: SimplexKey.h:27
Complex_vertex_range complex_vertex_range()
Returns a range over the vertices of the simplicial complex.
Definition: Simplex_tree.h:193
void print_hasse(std::ostream &os)
Write the hasse diagram of the simplicial complex in os.
Definition: Simplex_tree.h:780
void insert_graph(const OneSkeletonGraph &skel_graph)
Inserts a 1-skeleton in an empty Simplex_tree.
Definition: Simplex_tree.h:631
std::vector< Simplex_handle >::iterator Filtration_simplex_iterator
Iterator over the simplices of the simplicial complex, ordered by the filtration. ...
Definition: Simplex_tree.h:182
unspecified Indexing_tag
Specifies the nature of the indexing scheme.
Definition: FilteredComplex.h:44
FiltrationValue Filtration_value
Type for the value of the filtration function.
Definition: Simplex_tree.h:97
Simplex_tree_complex_simplex_iterator< Simplex_tree > Complex_simplex_iterator
Iterator over the simplices of the simplicial complex.
Definition: Simplex_tree.h:168
Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition: Simplex_tree.h:328
Simplex_tree_simplex_vertex_iterator< Simplex_tree > Simplex_vertex_iterator
Iterator over the vertices of a simplex.
Definition: Simplex_tree.h:156
Skeleton_simplex_range skeleton_simplex_range(int dim)
Returns a range over the simplices of the dim-skeleton of the simplicial complex. ...
Definition: Simplex_tree.h:218
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:32
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh)
Returns a range over the vertices of a simplex.
Definition: Simplex_tree.h:254
unspecified Boundary_simplex_range
Range giving access to the simplices in the boundary of a simplex.
Definition: FilteredComplex.h:85
int dimension(Simplex_handle sh)
Returns the dimension of a simplex.
Definition: Simplex_tree.h:370
boost::iterator_range< Boundary_simplex_iterator > Boundary_simplex_range
Range over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:164
void set_num_simplices(const unsigned int &num_simplices)
Definition: Simplex_tree.h:529
Vertex_handle null_vertex()
Returns a Vertex_handle different from all Vertex_handles associated to the vertices of the simplicia...
Definition: Simplex_tree.h:353
Simplex_tree_boundary_simplex_iterator< Simplex_tree > Boundary_simplex_iterator
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:162
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented byt he simplex tree...
Definition: Simplex_tree.h:126
int dimension()
Returns an upper bound on the dimension of the simplicial complex.
Definition: Simplex_tree.h:380
Filtration_simplex_range filtration_simplex_range(linear_indexing_tag)
Returns a range over the simplices of the simplicial complex, in the order of the filtration...
Definition: Simplex_tree.h:237
unspecified Filtration_simplex_range
Range over the simplices of the complex in the order of the filtration.
Definition: FilteredComplex.h:110
boost::iterator_range< Simplex_vertex_iterator > Simplex_vertex_range
Range over the vertices of a simplex.
Definition: Simplex_tree.h:158
Filtration_value filtration()
Returns an upper bound of the filtration values of the simplices.
Definition: Simplex_tree.h:336
boost::iterator_range< Complex_simplex_iterator > Complex_simplex_range
Range over the simplices of the simplicial complex.
Definition: Simplex_tree.h:170
boost::iterator_range< Skeleton_simplex_iterator > Skeleton_simplex_range
Range over the simplices of the skeleton of the simplicial complex, for a given dimension.
Definition: Simplex_tree.h:178
Siblings * self_siblings(Simplex_handle sh)
Definition: Simplex_tree.h:499
void set_dimension(int dimension)
Definition: Simplex_tree.h:533
const unsigned int & num_simplices() const
Returns the number of simplices in the complex.
Definition: Simplex_tree.h:363
std::pair< Simplex_handle, bool > insert(RandomAccessVertexRange &simplex, Filtration_value filtration)
Insert a simplex, represented by a range of Vertex_handles, in the simplicial complex.
Definition: Simplex_tree.h:452
Boundary_simplex_range boundary_simplex_range(Simplex_handle sh)
Returns a range over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:273
VertexHandle Vertex_handle
Type for the vertex handle.
Definition: Simplex_tree.h:105
Siblings * root()
Definition: Simplex_tree.h:519
boost::iterator_range< Complex_vertex_iterator > Complex_vertex_range
Range over the vertices of the simplicial complex.
Definition: Simplex_tree.h:152
std::pair< Simplex_handle, Simplex_handle > endpoints(Simplex_handle sh)
Definition: Simplex_tree.h:492
void expansion(int max_dim)
Expands the Simplex_tree containing only its one skeleton until dimension max_dim.
Definition: Simplex_tree.h:685
boost::iterator_range< Filtration_simplex_iterator > Filtration_simplex_range
Range over the simplices of the simplicial complex, ordered by the filtration.
Definition: Simplex_tree.h:184
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:26
size_t num_vertices()
Returns the number of vertices in the complex.
Definition: Simplex_tree.h:357
Simplex_tree()
Constructs an empty simplex tree.
Definition: Simplex_tree.h:283
bool has_children(Simplex_handle sh)
Returns true iff the node in the simplex tree pointed by sh has children.
Definition: Simplex_tree.h:386
unspecified Filtration_value
Type for the value of the filtration function.
Definition: FilteredComplex.h:39
Simplex_handle find_vertex(Vertex_handle v)
Returns the Simplex_handle corresponding to the 0-simplex representing the vertex with Vertex_handle ...
Definition: Simplex_tree.h:423
void initialize_filtration()
Initializes the filtrations, i.e. sort the simplices according to their order in the filtration and i...
Definition: Simplex_tree.h:553