23 #ifndef SIMPLEX_TREE_H_ 24 #define SIMPLEX_TREE_H_ 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> 32 #include <gudhi/graph_simplicial_complex.h> 33 #include <gudhi/Debug_utils.h> 35 #include <boost/container/flat_map.hpp> 36 #include <boost/iterator/transform_iterator.hpp> 37 #include <boost/graph/adjacency_list.hpp> 38 #include <boost/range/adaptor/reversed.hpp> 41 #include <tbb/parallel_sort.h> 49 #include <initializer_list> 56 struct Simplex_tree_options_full_featured;
71 template<
typename SimplexTreeOptions = Simplex_tree_options_full_featured>
90 typedef Simplex_tree_node_explicit_storage<Simplex_tree> Node;
95 typedef typename boost::container::flat_map<Vertex_handle, Node> Dictionary;
99 typedef Simplex_tree_siblings<Simplex_tree, Dictionary> Siblings;
101 struct Key_simplex_base_real {
102 Key_simplex_base_real() : key_(-1) {}
104 Simplex_key
key()
const {
return key_; }
108 struct Key_simplex_base_dummy {
109 Key_simplex_base_dummy() {}
112 Simplex_key
key()
const;
114 typedef typename std::conditional<Options::store_key, Key_simplex_base_real, Key_simplex_base_dummy>::type
117 struct Filtration_simplex_base_real {
118 Filtration_simplex_base_real() : filt_(0) {}
120 Filtration_value
filtration()
const {
return filt_; }
122 Filtration_value filt_;
124 struct Filtration_simplex_base_dummy {
125 Filtration_simplex_base_dummy() {}
126 void assign_filtration(Filtration_value GUDHI_CHECK_code(f)) { GUDHI_CHECK(f == 0,
"filtration value specified for a complex that does not store them"); }
127 Filtration_value
filtration()
const {
return 0; }
130 Filtration_simplex_base_dummy>::type Filtration_simplex_base;
138 typedef typename Dictionary::iterator Dictionary_it;
139 typedef typename Dictionary_it::value_type Dit_value_t;
141 struct return_first {
142 Vertex_handle operator()(
const Dit_value_t& p_sh)
const {
205 boost::make_transform_iterator(root_.members_.begin(), return_first()),
206 boost::make_transform_iterator(root_.members_.end(), return_first()));
249 if (filtration_vect_.empty()) {
252 return filtration_vect_;
281 template<
class SimplexHandle>
294 root_(nullptr, null_vertex_),
300 : null_vertex_(simplex_source.null_vertex_),
301 root_(nullptr, null_vertex_ , simplex_source.root_.members_),
303 dimension_(simplex_source.dimension_) {
304 auto root_source = simplex_source.root_;
309 void rec_copy(Siblings *sib, Siblings *sib_source) {
310 for (
auto sh = sib->members().begin(), sh_source = sib_source->members().begin();
311 sh != sib->members().end(); ++sh, ++sh_source) {
313 Siblings * newsib =
new Siblings(sib, sh_source->first);
314 newsib->members_.reserve(sh_source->second.children()->members().size());
315 for (
auto & child : sh_source->second.children()->members())
316 newsib->members_.emplace_hint(newsib->members_.end(), child.first, Node(newsib, child.second.filtration()));
317 rec_copy(newsib, sh_source->second.children());
318 sh->second.assign_children(newsib);
325 : null_vertex_(std::move(old.null_vertex_)),
326 root_(std::move(old.root_)),
327 filtration_vect_(std::move(old.filtration_vect_)),
328 dimension_(std::move(old.dimension_)) {
330 old.root_ = Siblings(
nullptr, null_vertex_);
335 for (
auto sh = root_.members().begin(); sh != root_.members().end(); ++sh) {
337 rec_delete(sh->second.children());
344 void rec_delete(Siblings * sib) {
345 for (
auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) {
347 rec_delete(sh->second.children());
356 if ((null_vertex_ != st2.null_vertex_) ||
357 (dimension_ != st2.dimension_))
359 return rec_equal(&root_, &st2.root_);
364 return (!(*
this == st2));
369 bool rec_equal(Siblings* s1, Siblings* s2) {
370 if (s1->members().size() != s2->members().size())
372 for (
auto sh1 = s1->members().begin(), sh2 = s2->members().begin();
373 (sh1 != s1->members().end() && sh2 != s2->members().end()); ++sh1, ++sh2) {
374 if (sh1->first != sh2->first || sh1->second.filtration() != sh2->second.filtration())
380 if (!rec_equal(sh1->second.children(), sh2->second.children()))
392 static Simplex_key
key(Simplex_handle sh) {
393 return sh->second.key();
401 Simplex_handle
simplex(Simplex_key idx)
const {
402 return filtration_vect_[idx];
412 return sh->second.filtration();
414 return std::numeric_limits<Filtration_value>::infinity();
423 std::invalid_argument(
"Simplex_tree::assign_filtration - cannot assign filtration on null_simplex"));
424 sh->second.assign_filtration(fv);
432 return Dictionary_it(
nullptr);
449 return root_.members_.size();
461 auto sib_begin = sib->members().begin();
462 auto sib_end = sib->members().end();
463 size_t simplices_number = sib_end - sib_begin;
464 for (
auto sh = sib_begin; sh != sib_end; ++sh) {
469 return simplices_number;
479 while (curr_sib !=
nullptr) {
481 curr_sib = curr_sib->oncles();
496 if (dimension_to_be_lowered_)
497 lower_upper_bound_dimension();
503 template<
class SimplexHandle>
506 return (sh->second.children()->parent() == sh->first);
516 template<
class InputVertexRange = std::initializer_list<Vertex_handle>>
517 Simplex_handle
find(
const InputVertexRange & s) {
518 auto first = std::begin(s);
519 auto last = std::end(s);
525 std::vector<Vertex_handle> copy(first, last);
526 std::sort(std::begin(copy), std::end(copy));
527 return find_simplex(copy);
532 Simplex_handle find_simplex(
const std::vector<Vertex_handle> &
simplex) {
533 Siblings * tmp_sib = &root_;
534 Dictionary_it tmp_dit;
535 auto vi = simplex.begin();
538 GUDHI_CHECK(contiguous_vertices(),
"non-contiguous vertices");
539 Vertex_handle v = *vi++;
540 if(v < 0 || v >= static_cast<Vertex_handle>(root_.members_.size()))
542 tmp_dit = root_.members_.begin() + v;
543 if (vi == simplex.end())
547 tmp_sib = tmp_dit->second.children();
550 tmp_dit = tmp_sib->members_.find(*vi++);
551 if (tmp_dit == tmp_sib->members_.end())
553 if (vi == simplex.end())
557 tmp_sib = tmp_dit->second.children();
563 Simplex_handle find_vertex(Vertex_handle v) {
565 assert(contiguous_vertices());
566 return root_.members_.begin() + v;
568 return root_.members_.find(v);
574 bool contiguous_vertices()
const {
575 if (root_.members_.empty())
return true;
576 if (root_.members_.begin()->first != 0)
return false;
577 if (std::prev(root_.members_.end())->first != static_cast<Vertex_handle>(root_.members_.size() - 1))
return false;
596 std::pair<Simplex_handle, bool> insert_vertex_vector(
const std::vector<Vertex_handle>& simplex,
598 Siblings * curr_sib = &root_;
599 std::pair<Simplex_handle, bool> res_insert;
600 auto vi = simplex.begin();
601 for (; vi != simplex.end() - 1; ++vi) {
602 GUDHI_CHECK(*vi !=
null_vertex(),
"cannot use the dummy null_vertex() as a real vertex");
603 res_insert = curr_sib->members_.emplace(*vi, Node(curr_sib, filtration));
605 res_insert.first->second.assign_children(
new Siblings(curr_sib, *vi));
607 curr_sib = res_insert.first->second.children();
609 GUDHI_CHECK(*vi !=
null_vertex(),
"cannot use the dummy null_vertex() as a real vertex");
610 res_insert = curr_sib->members_.emplace(*vi, Node(curr_sib, filtration));
611 if (!res_insert.second) {
613 if (res_insert.first->second.filtration() >
filtration) {
615 res_insert.first->second.assign_filtration(filtration);
619 return std::pair<Simplex_handle, bool>(
null_simplex(),
false);
622 if (static_cast<int>(simplex.size()) - 1 > dimension_) {
624 dimension_ =
static_cast<int>(simplex.size()) - 1;
653 template<
class InputVertexRange = std::initializer_list<Vertex_handle>>
655 Filtration_value filtration = 0) {
656 auto first = std::begin(simplex);
657 auto last = std::end(simplex);
660 return std::pair<Simplex_handle, bool>(
null_simplex(),
true);
663 std::vector<Vertex_handle> copy(first, last);
664 std::sort(std::begin(copy), std::end(copy));
665 return insert_vertex_vector(copy, filtration);
682 template<
class InputVertexRange = std::initializer_list<Vertex_handle>>
684 Filtration_value filtration = 0) {
685 auto first = std::begin(Nsimplex);
686 auto last = std::end(Nsimplex);
693 #ifdef GUDHI_CAN_USE_CXX11_THREAD_LOCAL 695 #endif // GUDHI_CAN_USE_CXX11_THREAD_LOCAL 696 std::vector<Vertex_handle> copy;
698 copy.insert(copy.end(), first, last);
699 std::sort(std::begin(copy), std::end(copy));
701 for (Vertex_handle v : copy)
702 GUDHI_CHECK(v !=
null_vertex(),
"cannot use the dummy null_vertex() as a real vertex");
705 return insert_simplex_and_subfaces_sorted(copy, filtration);
710 template<
class ForwardVertexRange = std::initializer_list<Vertex_handle>>
711 std::pair<Simplex_handle, bool> insert_simplex_and_subfaces_sorted(
const ForwardVertexRange& Nsimplex, Filtration_value filt = 0) {
712 auto first = std::begin(Nsimplex);
713 auto last = std::end(Nsimplex);
716 GUDHI_CHECK(std::is_sorted(first, last),
"simplex vertices listed in unsorted order");
718 dimension_ = (std::max)(dimension_, static_cast<int>(std::distance(first, last)) - 1);
719 return rec_insert_simplex_and_subfaces_sorted(
root(), first, last, filt);
722 template<
class ForwardVertexIterator>
723 std::pair<Simplex_handle, bool> rec_insert_simplex_and_subfaces_sorted(Siblings* sib, ForwardVertexIterator first, ForwardVertexIterator last, Filtration_value filt) {
728 Vertex_handle vertex_one = *first;
729 auto&& dict = sib->members();
730 auto insertion_result = dict.emplace(vertex_one, Node(sib, filt));
731 Simplex_handle simplex_one = insertion_result.first;
732 bool one_is_new = insertion_result.second;
741 if (++first == last)
return insertion_result;
744 simplex_one->second.assign_children(
new Siblings(sib, vertex_one));
745 auto res = rec_insert_simplex_and_subfaces_sorted(simplex_one->second.children(), first, last, filt);
747 if (res.first !=
null_simplex()) rec_insert_simplex_and_subfaces_sorted(sib, first, last, filt);
755 sh->second.assign_key(key);
761 std::pair<Simplex_handle, Simplex_handle>
endpoints(Simplex_handle sh) {
763 return { find_vertex(sh->first), find_vertex(
self_siblings(sh)->parent()) };
767 template<
class SimplexHandle>
769 if (sh->second.children()->parent() == sh->first)
770 return sh->second.children()->oncles();
772 return sh->second.children();
786 dimension_to_be_lowered_ =
false;
801 filtration_vect_.clear();
804 filtration_vect_.push_back(sh);
816 tbb::parallel_sort(filtration_vect_.begin(), filtration_vect_.end(), is_before_in_filtration(
this));
818 std::stable_sort(filtration_vect_.begin(), filtration_vect_.end(), is_before_in_filtration(
this));
835 void rec_coface(std::vector<Vertex_handle> &vertices, Siblings *curr_sib,
int curr_nbVertices,
836 std::vector<Simplex_handle>& cofaces,
bool star,
int nbVertices) {
837 if (!(star || curr_nbVertices <= nbVertices))
839 for (Simplex_handle simplex = curr_sib->members().begin(); simplex != curr_sib->members().end(); ++
simplex) {
840 if (vertices.empty()) {
845 bool addCoface = (star || curr_nbVertices == nbVertices);
847 cofaces.push_back(simplex);
849 rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
851 if (simplex->first == vertices.back()) {
853 bool equalDim = (star || curr_nbVertices == nbVertices);
854 bool addCoface = vertices.size() == 1 && equalDim;
856 cofaces.push_back(simplex);
859 Vertex_handle tmp = vertices.back();
861 rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
862 vertices.push_back(tmp);
864 }
else if (simplex->first > vertices.back()) {
869 rec_coface(vertices, simplex->second.children(), curr_nbVertices + 1, cofaces, star, nbVertices);
893 Cofaces_simplex_range cofaces;
895 assert(codimension >= 0);
897 std::vector<Vertex_handle> copy(rg.begin(), rg.end());
898 if (codimension + static_cast<int>(copy.size()) > dimension_ + 1 ||
899 (codimension == 0 && static_cast<int>(copy.size()) > dimension_))
902 assert(std::is_sorted(copy.begin(), copy.end(), std::greater<Vertex_handle>()));
903 bool star = codimension == 0;
904 rec_coface(copy, &root_, 1, cofaces, star, codimension + static_cast<int>(copy.size()));
916 bool reverse_lexicographic_order(Simplex_handle sh1, Simplex_handle sh2) {
919 Simplex_vertex_iterator it1 = rg1.begin();
920 Simplex_vertex_iterator it2 = rg2.begin();
921 while (it1 != rg1.end() && it2 != rg2.end()) {
929 return ((it1 == rg1.end()) && (it2 != rg2.end()));
938 struct is_before_in_filtration {
942 bool operator()(
const Simplex_handle sh1,
const Simplex_handle sh2)
const {
944 if (sh1->second.filtration() != sh2->second.filtration()) {
945 return sh1->second.filtration() < sh2->second.filtration();
948 return st_->reverse_lexicographic_order(sh1, sh2);
977 template<
class OneSkeletonGraph>
982 if (boost::num_vertices(skel_graph) == 0) {
985 if (num_edges(skel_graph) == 0) {
991 root_.members_.reserve(boost::num_vertices(skel_graph));
993 typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator v_it,
995 for (std::tie(v_it, v_it_end) = boost::vertices(skel_graph); v_it != v_it_end;
997 root_.members_.emplace_hint(
998 root_.members_.end(), *v_it,
999 Node(&root_, boost::get(vertex_filtration_t(), skel_graph, *v_it)));
1001 typename boost::graph_traits<OneSkeletonGraph>::edge_iterator e_it,
1003 for (std::tie(e_it, e_it_end) = boost::edges(skel_graph); e_it != e_it_end;
1005 auto u = source(*e_it, skel_graph);
1006 auto v = target(*e_it, skel_graph);
1007 if (u == v)
throw "Self-loops are not simplicial";
1015 if (v < u) std::swap(u, v);
1016 auto sh = find_vertex(u);
1018 sh->second.assign_children(
new Siblings(&root_, sh->first));
1021 sh->second.children()->members().emplace(v,
1022 Node(sh->second.children(), boost::get(edge_filtration_t(), skel_graph, *e_it)));
1038 dimension_ = max_dim;
1039 for (Dictionary_it root_it = root_.members_.begin();
1040 root_it != root_.members_.end(); ++root_it) {
1042 siblings_expansion(root_it->second.children(), max_dim - 1);
1045 dimension_ = max_dim - dimension_;
1050 void siblings_expansion(Siblings * siblings,
1052 if (dimension_ > k) {
1057 Dictionary_it next = siblings->members().begin();
1060 #ifdef GUDHI_CAN_USE_CXX11_THREAD_LOCAL 1062 #endif // GUDHI_CAN_USE_CXX11_THREAD_LOCAL 1063 std::vector<std::pair<Vertex_handle, Node> > inter;
1064 for (Dictionary_it s_h = siblings->members().begin();
1065 s_h != siblings->members().end(); ++s_h, ++next) {
1066 Simplex_handle root_sh = find_vertex(s_h->first);
1071 siblings->members().end(),
1072 root_sh->second.children()->members().begin(),
1073 root_sh->second.children()->members().end(),
1074 s_h->second.filtration());
1075 if (inter.size() != 0) {
1076 Siblings * new_sib =
new Siblings(siblings,
1080 s_h->second.assign_children(new_sib);
1081 siblings_expansion(new_sib, k - 1);
1084 s_h->second.assign_children(siblings);
1093 static void intersection(std::vector<std::pair<Vertex_handle, Node> >& intersection,
1094 Dictionary_it begin1, Dictionary_it end1,
1095 Dictionary_it begin2, Dictionary_it end2,
1096 Filtration_value filtration_) {
1097 if (begin1 == end1 || begin2 == end2)
1100 if (begin1->first == begin2->first) {
1101 Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_});
1102 intersection.emplace_back(begin1->first, Node(
nullptr, filt));
1103 if (++begin1 == end1 || ++begin2 == end2)
1105 }
else if (begin1->first < begin2->first) {
1106 if (++begin1 == end1)
1109 if (++begin2 == end2)
1134 template<
typename Blocker >
1137 for (
auto& simplex : boost::adaptors::reverse(root_.members())) {
1139 siblings_expansion_with_blockers(simplex.second.children(), max_dim, max_dim - 1, block_simplex);
1146 template<
typename Blocker >
1147 void siblings_expansion_with_blockers(Siblings* siblings,
int max_dim,
int k, Blocker block_simplex) {
1148 if (dimension_ < max_dim - k) {
1149 dimension_ = max_dim - k;
1154 if (siblings->members().size() < 2)
1157 for (
auto simplex = siblings->members().rbegin() + 1; simplex != siblings->members().rend(); simplex++) {
1158 std::vector<std::pair<Vertex_handle, Node> > intersection;
1159 for(
auto next = siblings->members().rbegin(); next !=
simplex; next++) {
1160 bool to_be_inserted =
true;
1161 Filtration_value filt = simplex->second.filtration();
1164 Simplex_handle border_child = find_child(border, next->first);
1166 to_be_inserted=
false;
1169 filt = (std::max)(filt,
filtration(border_child));
1171 if (to_be_inserted) {
1172 intersection.emplace_back(next->first, Node(
nullptr, filt));
1175 if (intersection.size() != 0) {
1177 Siblings * new_sib =
new Siblings(siblings,
1179 boost::adaptors::reverse(intersection));
1180 std::vector<Vertex_handle> blocked_new_sib_vertex_list;
1182 for (
auto new_sib_member = new_sib->members().begin();
1183 new_sib_member != new_sib->members().end();
1185 bool blocker_result = block_simplex(new_sib_member);
1188 if (blocker_result) {
1189 blocked_new_sib_vertex_list.push_back(new_sib_member->first);
1192 if (blocked_new_sib_vertex_list.size() == new_sib->members().size()) {
1196 simplex->second.assign_children(siblings);
1198 for (
auto& blocked_new_sib_member : blocked_new_sib_vertex_list) {
1199 new_sib->members().erase(blocked_new_sib_member);
1202 simplex->second.assign_children(new_sib);
1203 siblings_expansion_with_blockers(new_sib, max_dim, k - 1, block_simplex);
1207 simplex->second.assign_children(siblings);
1216 Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh)
const {
1220 Simplex_handle child = sh->second.children()->find(vh);
1223 if (child == sh->second.children()->members().end())
1241 os <<
key(b_sh) <<
" ";
1256 bool modified =
false;
1258 for (
auto& simplex : boost::adaptors::reverse(root_.members())) {
1260 modified |= rec_make_filtration_non_decreasing(simplex.second.children());
1271 bool rec_make_filtration_non_decreasing(Siblings * sib) {
1272 bool modified =
false;
1275 for (
auto& simplex : boost::adaptors::reverse(sib->members())) {
1278 Boundary_simplex_iterator max_border = std::max_element(std::begin(boundary), std::end(boundary),
1279 [](Simplex_handle sh1, Simplex_handle sh2) {
1283 Filtration_value max_filt_border_value =
filtration(*max_border);
1284 if (simplex.second.filtration() < max_filt_border_value) {
1287 simplex.second.assign_filtration(max_filt_border_value);
1290 modified |= rec_make_filtration_non_decreasing(simplex.second.children());
1309 return rec_prune_above_filtration(
root(), filtration);
1313 bool rec_prune_above_filtration(Siblings* sib, Filtration_value filt) {
1314 auto&& list = sib->members();
1315 auto last = std::remove_if(list.begin(), list.end(), [=](Dit_value_t&
simplex) {
1316 if (simplex.second.filtration() <= filt)
return false;
1317 if (
has_children(&simplex)) rec_delete(simplex.second.children());
1319 dimension_to_be_lowered_ =
true;
1323 bool modified = (last != list.end());
1324 if (last == list.begin() && sib !=
root()) {
1326 sib->oncles()->members()[sib->parent()].assign_children(sib->oncles());
1329 dimension_to_be_lowered_ =
true;
1333 list.erase(last, list.end());
1334 for (
auto&& simplex : list)
1336 modified |= rec_prune_above_filtration(simplex.second.children(), filt);
1347 bool lower_upper_bound_dimension() {
1349 dimension_to_be_lowered_ =
false;
1350 int new_dimension = -1;
1355 std::cout <<
" " << vertex;
1357 std::cout << std::endl;
1358 #endif // DEBUG_TRACES 1361 if (sh_dimension >= dimension_)
1364 new_dimension = (std::max)(new_dimension, sh_dimension);
1366 dimension_ = new_dimension;
1384 std::invalid_argument(
"Simplex_tree::remove_maximal_simplex - argument has children"));
1387 Siblings* child = sh->second.children();
1389 if ((child->size() > 1) || (child ==
root())) {
1395 child->oncles()->members().at(child->parent()).assign_children(child->oncles());
1398 dimension_to_be_lowered_ =
true;
1403 Vertex_handle null_vertex_;
1408 std::vector<Simplex_handle> filtration_vect_;
1411 bool dimension_to_be_lowered_ =
false;
1415 template<
typename...T>
1427 template<
typename...T>
1430 std::vector<typename ST::Vertex_handle>
simplex;
1436 int dim =
static_cast<int> (simplex.size() - 1);
1437 if (max_dim < dim) {
1458 static const bool store_key =
true;
1459 static const bool store_filtration =
true;
1460 static const bool contiguous_vertices =
false;
1474 static const bool store_key =
true;
1475 static const bool store_filtration =
true;
1476 static const bool contiguous_vertices =
true;
1483 #endif // SIMPLEX_TREE_H_ 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:186
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree...
Definition: Simplex_tree.h:135
bool prune_above_filtration(Filtration_value filtration)
Prune above filtration value given as parameter.
Definition: Simplex_tree.h:1308
void expansion(int max_dim)
Expands the Simplex_tree containing only its one skeleton until dimension max_dim.
Definition: Simplex_tree.h:1037
Filtration_simplex_range::const_iterator Filtration_simplex_iterator
Iterator over the simplices of the simplicial complex, ordered by the filtration. ...
Definition: Simplex_tree.h:195
Tag for a linear ordering of simplices.
Definition: indexing_tag.h:32
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:72
Siblings * self_siblings(SimplexHandle sh)
Definition: Simplex_tree.h:768
std::pair< Simplex_handle, bool > insert_simplex_and_subfaces(const InputVertexRange &Nsimplex, Filtration_value filtration=0)
Insert a N-simplex and all his subfaces, from a N-simplex represented by a range of Vertex_handles...
Definition: Simplex_tree.h:683
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:754
bool operator==(Simplex_tree &st2)
Checks if two simplex trees are equal.
Definition: Simplex_tree.h:355
Concept describing an indexing scheme (see FilteredComplex) for applying continuous maps to a cell co...
Definition: IndexingTag.h:30
static Simplex_key key(Simplex_handle sh)
Returns the key associated to a simplex.
Definition: Simplex_tree.h:392
static Simplex_handle null_simplex()
Returns a Simplex_handle different from all Simplex_handles associated to the simplices in the simpli...
Definition: Simplex_tree.h:431
static constexpr bool contiguous_vertices
If true, the list of vertices present in the complex must always be 0, ..., num_vertices-1, without any hole.
Definition: SimplexTreeOptions.h:41
boost::iterator_range< Complex_vertex_iterator > Complex_vertex_range
Range over the vertices of the simplicial complex.
Definition: Simplex_tree.h:161
Vertex_handle null_vertex() const
Returns a Vertex_handle different from all Vertex_handles associated to the vertices of the simplicia...
Definition: Simplex_tree.h:443
Simplex_tree_simplex_vertex_iterator< Simplex_tree > Simplex_vertex_iterator
Iterator over the vertices of a simplex.
Definition: Simplex_tree.h:165
Definition: SimplicialComplexForAlpha.h:26
void print_hasse(std::ostream &os)
Write the hasse diagram of the simplicial complex in os.
Definition: Simplex_tree.h:1236
Key type used as simplex identifier.
Definition: SimplexKey.h:27
Siblings * root()
Definition: Simplex_tree.h:777
Simplex_tree(Simplex_tree &&old)
User-defined move constructor moves the whole tree structure.
Definition: Simplex_tree.h:324
Options::Simplex_key Simplex_key
Key associated to each simplex.
Definition: Simplex_tree.h:83
bool operator!=(Simplex_tree &st2)
Checks if two simplex trees are different.
Definition: Simplex_tree.h:363
bool make_filtration_non_decreasing()
This function ensures that each simplex has a higher filtration value than its faces by increasing th...
Definition: Simplex_tree.h:1255
std::vector< Simplex_handle > Filtration_simplex_range
Range over the simplices of the simplicial complex, ordered by the filtration.
Definition: Simplex_tree.h:191
int dimension()
Returns the dimension of the simplicial complex.
Definition: Simplex_tree.h:495
Filtration_simplex_range const & filtration_simplex_range(Indexing_tag=Indexing_tag())
Returns a range over the simplices of the simplicial complex, in the order of the filtration...
Definition: Simplex_tree.h:248
void initialize_filtration()
Initializes the filtrations, i.e. sort the simplices according to their order in the filtration and i...
Definition: Simplex_tree.h:800
Simplex_handle find(const InputVertexRange &s)
Given a range of Vertex_handles, returns the Simplex_handle of the simplex in the simplicial complex ...
Definition: Simplex_tree.h:517
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:32
Cofaces_simplex_range cofaces_simplex_range(const Simplex_handle simplex, int codimension)
Compute the cofaces of a n simplex.
Definition: Simplex_tree.h:892
Complex_simplex_range complex_simplex_range()
Returns a range over the simplices of the simplicial complex.
Definition: Simplex_tree.h:214
Concept of the template parameter for the class Gudhi::Simplex_tree<SimplexTreeOptions>.
Definition: SimplexTreeOptions.h:27
size_t num_vertices() const
Returns the number of vertices in the complex.
Definition: Simplex_tree.h:448
void assign_filtration(Simplex_handle sh, Filtration_value fv)
Sets the filtration value of a simplex.
Definition: Simplex_tree.h:421
std::pair< Simplex_handle, Simplex_handle > endpoints(Simplex_handle sh)
Definition: Simplex_tree.h:761
Boundary_simplex_range boundary_simplex_range(SimplexHandle sh)
Returns a range over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:282
Complex_vertex_range complex_vertex_range()
Returns a range over the vertices of the simplicial complex. The order is increasing according to < o...
Definition: Simplex_tree.h:203
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh)
Returns a range over the vertices of a simplex.
Definition: Simplex_tree.h:261
Options::Vertex_handle Vertex_handle
Type for the vertex handle.
Definition: Simplex_tree.h:87
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:228
boost::iterator_range< Boundary_simplex_iterator > Boundary_simplex_range
Range over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:175
bool has_children(SimplexHandle sh) const
Returns true if the node in the simplex tree pointed by sh has children.
Definition: Simplex_tree.h:504
Cofaces_simplex_range star_simplex_range(const Simplex_handle simplex)
Compute the star of a n simplex.
Definition: Simplex_tree.h:881
void set_dimension(int dimension)
Set a dimension for the simplicial complex.
Definition: Simplex_tree.h:785
int upper_bound_dimension() const
Returns an upper bound on the dimension of the simplicial complex.
Definition: Simplex_tree.h:487
int dimension(Simplex_handle sh)
Returns the dimension of a simplex.
Definition: Simplex_tree.h:476
static Simplex_key null_key()
Returns a key different for all keys associated to the simplices of the simplicial complex...
Definition: Simplex_tree.h:437
static Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition: Simplex_tree.h:410
bool read_simplex(std::istream &in_, std::vector< Vertex_handle > &simplex, Filtration_value &fil)
Read a face from a file.
Definition: reader_utils.h:170
Definition: Simplex_tree.h:1469
Definition: Simplex_tree.h:1453
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:27
boost::transform_iterator< return_first, Dictionary_it > Complex_vertex_iterator
Iterator over the vertices of the simplicial complex.
Definition: Simplex_tree.h:159
~Simplex_tree()
Destructor; deallocates the whole tree structure.
Definition: Simplex_tree.h:334
void remove_maximal_simplex(Simplex_handle sh)
Remove a maximal simplex.
Definition: Simplex_tree.h:1381
static const bool store_filtration
If true, each simplex has extra storage for one Filtration_value, and this value is propagated by ope...
Definition: SimplexTreeOptions.h:39
size_t num_simplices()
returns the number of simplices in the simplex_tree.
Definition: Simplex_tree.h:454
boost::iterator_range< Complex_simplex_iterator > Complex_simplex_range
Range over the simplices of the simplicial complex.
Definition: Simplex_tree.h:181
Options::Filtration_value Filtration_value
Type for the value of the filtration function.
Definition: Simplex_tree.h:79
Simplex_tree()
Constructs an empty simplex tree.
Definition: Simplex_tree.h:292
Simplex_tree_boundary_simplex_iterator< Simplex_tree > Boundary_simplex_iterator
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree.h:173
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:189
Simplex_tree_complex_simplex_iterator< Simplex_tree > Complex_simplex_iterator
Iterator over the simplices of the simplicial complex.
Definition: Simplex_tree.h:179
void insert_graph(const OneSkeletonGraph &skel_graph)
Inserts a 1-skeleton in an empty Simplex_tree.
Definition: Simplex_tree.h:978
Simplex_handle simplex(Simplex_key idx) const
Returns the simplex that has index idx in the filtration.
Definition: Simplex_tree.h:401
Simplex_tree(const Simplex_tree &simplex_source)
User-defined copy constructor reproduces the whole tree structure.
Definition: Simplex_tree.h:299
This file includes common file reader for GUDHI.
boost::iterator_range< Simplex_vertex_iterator > Simplex_vertex_range
Range over the vertices of a simplex.
Definition: Simplex_tree.h:167
std::pair< Simplex_handle, bool > insert_simplex(const InputVertexRange &simplex, Filtration_value filtration=0)
Insert a simplex, represented by a range of Vertex_handles, in the simplicial complex.
Definition: Simplex_tree.h:654
void expansion_with_blockers(int max_dim, Blocker block_simplex)
Expands a simplex tree containing only a graph. Simplices corresponding to cliques in the graph are a...
Definition: Simplex_tree.h:1135
void rec_copy(Siblings *sib, Siblings *sib_source)
depth first search, inserts simplices when reaching a leaf.
Definition: Simplex_tree.h:309
std::vector< Simplex_handle > Cofaces_simplex_range
Range over the cofaces of a simplex.
Definition: Simplex_tree.h:169