diff options
author | Ulrich Bauer <mail@ulrich-bauer.org> | 2016-09-29 23:03:12 +0200 |
---|---|---|
committer | Ulrich Bauer <mail@ulrich-bauer.org> | 2016-09-29 23:03:12 +0200 |
commit | 77deb431e86bab1b4d3716909fc061ac52f692f1 (patch) | |
tree | 3b11b6296fd6cf054eb5803a4a67832b4f00b9da | |
parent | 43d28e6cea16062d0cefaf16979d07837cc788d6 (diff) |
sparse graph support for dim 0
-rw-r--r-- | ripser.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -982,17 +982,22 @@ int main(int argc, char** argv) { std::vector<diameter_index_t> columns_to_reduce; std::vector<diameter_index_t> simplices , &edges = simplices; - rips_filtration_comparator<decltype(dist)> comp(dist, 1, binomial_coeff); - for (index_t index = binomial_coeff(n, 2); index-- > 0;) { - value_t diameter = comp.diameter(index); - if (diameter <= threshold) edges.push_back(std::make_pair(diameter, index)); + + for (index_t i = 0; i < n; ++i) { + simplex_coboundary_enumerator<const sparse_distance_matrix&> cofaces(i, 0, n, modulus, sparse_dist, binomial_coeff); + + while (cofaces.has_next(false)) { + auto coface = cofaces.next(); + value_t diameter = get_diameter(coface); + if (diameter <= threshold) edges.push_back(std::make_pair(diameter, get_index(coface))); + } + + std::sort(edges.rbegin(), edges.rend(), greater_diameter_or_smaller_index<diameter_index_t>()); } { union_find dset(n); - std::sort(edges.rbegin(), edges.rend(), greater_diameter_or_smaller_index<diameter_index_t>()); - #ifdef PRINT_PERSISTENCE_PAIRS std::cout << "persistence intervals in dim 0:" << std::endl; #endif |