Skip to content

Commit

Permalink
Don't use skeleton_simplex_range in Persistent_cohomology
Browse files Browse the repository at this point in the history
It wasn't part of the documented concept...
  • Loading branch information
mglisse committed Jul 26, 2023
1 parent e277777 commit 6d7aaa9
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ class Persistent_cohomology {
// num_simplices must be strictly lower than the limit, because a value is reserved for null_key.
throw std::out_of_range("The number of simplices is more than Simplex_key type numeric limit.");
}
Simplex_key idx_fil = 0;
for (auto sh : cpx_->filtration_simplex_range()) {
cpx_->assign_key(sh, idx_fil);
++idx_fil;
dsets_.make_set(cpx_->key(sh));
}
if (persistence_dim_max) {
++dim_max_;
}
Expand Down Expand Up @@ -172,11 +166,16 @@ class Persistent_cohomology {
* valid. Undefined behavior otherwise. */
void compute_persistent_cohomology(Filtration_value min_interval_length = 0) {
interval_length_policy.set_length(min_interval_length);
Simplex_key idx_fil = -1;
std::vector<Simplex_key> vertices; // so we can check the connected components at the end
// Compute all finite intervals
for (auto sh : cpx_->filtration_simplex_range()) {
cpx_->assign_key(sh, ++idx_fil);
dsets_.make_set(cpx_->key(sh));
int dim_simplex = cpx_->dimension(sh);
switch (dim_simplex) {
case 0:
vertices.push_back(idx_fil);
break;
case 1:
update_cohomology_groups_edge(sh);
Expand All @@ -187,10 +186,7 @@ class Persistent_cohomology {
}
}
// Compute infinite intervals of dimension 0
Simplex_key key;
for (auto v_sh : cpx_->skeleton_simplex_range(0)) { // for all 0-dimensional simplices
key = cpx_->key(v_sh);

for (Simplex_key key : vertices) { // for all 0-dimensional simplices
if (ds_parent_[key] == key // root of its tree
&& zero_cocycles_.find(key) == zero_cocycles_.end()) {
persistent_pairs_.emplace_back(
Expand Down

0 comments on commit 6d7aaa9

Please sign in to comment.