Skip to content

Commit

Permalink
merge upstream part1
Browse files Browse the repository at this point in the history
  • Loading branch information
hschreiber committed Jan 8, 2025
1 parent da86ef5 commit 0655678
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 245 deletions.
2 changes: 1 addition & 1 deletion src/Zigzag_persistence/concept/ZigzagOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct FilteredZigzagOptions {
* @brief Type for the face IDs used at insertion and in the boundaries given as argument.
* Has to be usable as key in a hashtable, so "hashable" and comparable.
*/
using Face_key = unspecified;
using Cell_key = unspecified;

/**
* @brief Type for filtration values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ int main() {
// filtration values are monotonous (ie., either only increasing or only decreasing).

// inserts vertex 2 at filtration value 0.1 -> birth at 0.1 of 0-cycle
zp.insert_face(2, {}, 0, 0.1);
zp.insert_cell(2, {}, 0, 0.1);
// inserts vertex 4 at filtration value 0.1 -> birth at 0.1 of 0-cycle
zp.insert_face(4, {}, 0, 0.1);
zp.insert_cell(4, {}, 0, 0.1);
// inserts edge 5 = (2,4) at filtration value 0.3 -> death at 0.3 -> outputs (0, 0.1, 0.3)
zp.insert_face(5, {2, 4}, 1, 0.3);
zp.insert_cell(5, {2, 4}, 1, 0.3);
// inserts vertex 3 at filtration value 0.4 -> birth at 0.4 of 0-cycle
zp.insert_face(3, {}, 0, 0.4);
zp.insert_cell(3, {}, 0, 0.4);
// inserts edge 6 = (2,3) at filtration value 0.4 -> death at 0.4 of the cycle born at 0.4 -> outputs nothing
zp.insert_face(6, {2, 3}, 1, 0.4);
zp.insert_cell(6, {2, 3}, 1, 0.4);
// inserts edge 9 = (3,4) at filtration value 1.2 -> birth at 1.2 of 1-cycle
zp.insert_face(9, {4, 3}, 1, 1.2);
zp.insert_cell(9, {4, 3}, 1, 1.2);
// removes edge 6 at filtration value 1.5 -> death at 1.5 -> outputs (1, 1.2, 1.5)
zp.remove_face(6, 1.5);
zp.remove_cell(6, 1.5);
// removes edge 5 at filtration value 2.0 -> birth at 2.0 of 0-cycle
zp.remove_face(5, 2.0);
zp.remove_cell(5, 2.0);

// Only the closed bars where output so far, so the open/infinite bars still need to be retrieved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ int main() {
// filtration values are monotonous (ie., either only increasing or only decreasing).

// inserts vertex 2 at filtration value 0.1 -> birth at 0.1 of 0-cycle
zp.insert_face(2, {}, 0, 0.1);
zp.insert_cell(2, {}, 0, 0.1);
// inserts vertex 4 at filtration value 0.1 -> birth at 0.1 of 0-cycle
zp.insert_face(4, {}, 0, 0.1);
zp.insert_cell(4, {}, 0, 0.1);
// inserts edge 5 = (2,4) at filtration value 0.3 -> death at 0.3 -> stores (0, 0.1, 0.3)
zp.insert_face(5, {2, 4}, 1, 0.3);
zp.insert_cell(5, {2, 4}, 1, 0.3);
// inserts vertex 3 at filtration value 0.4 -> birth at 0.4 of 0-cycle
zp.insert_face(3, {}, 0, 0.4);
zp.insert_cell(3, {}, 0, 0.4);
// inserts edge 6 = (2,3) at filtration value 0.4 -> death at 0.4 of the cycle born at 0.4 -> stores nothing
zp.insert_face(6, {2, 3}, 1, 0.4);
zp.insert_cell(6, {2, 3}, 1, 0.4);
// inserts edge 9 = (3,4) at filtration value 1.2 -> birth at 1.2 of 1-cycle
zp.insert_face(9, {4, 3}, 1, 1.2);
zp.insert_cell(9, {4, 3}, 1, 1.2);
// removes edge 6 at filtration value 1.5 -> death at 1.5 -> stores (1, 1.2, 1.5)
zp.remove_face(6, 1.5);
zp.remove_cell(6, 1.5);
// removes edge 5 at filtration value 2.0 -> birth at 2.0 of 0-cycle
zp.remove_face(5, 2.0);
zp.remove_cell(5, 2.0);

// The bars are stored within the class and where not output at all for now.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ int main() {
// A face has to be identified in the boundaries by the operation number the face was inserted with in the sequence.

// inserts vertex 0 -> birth at 0 of 0-cycle
zp.insert_face({}, 0);
zp.insert_cell({}, 0);
// inserts vertex 1 -> birth at 1 of 0-cycle
zp.insert_face({}, 0);
zp.insert_cell({}, 0);
// inserts edge 2 = (0,1) -> death at 2 -> outputs (0, 1, 2)
zp.insert_face({0, 1}, 1);
zp.insert_cell({0, 1}, 1);
// inserts vertex 3 -> birth at 3 of 0-cycle
zp.insert_face({}, 0);
zp.insert_cell({}, 0);
// inserts edge 4 = (0,3) -> death at 4 -> outputs (0, 3, 4)
zp.insert_face({0, 3}, 1);
zp.insert_cell({0, 3}, 1);
// inserts edge 5 = (1,3) -> birth at 5 of 1-cycle
zp.insert_face({1, 3}, 1);
zp.insert_cell({1, 3}, 1);
// removes edge 4 -> death at 6 -> outputs (1, 5, 6)
zp.remove_face(4);
zp.remove_cell(4);
// removes edge 2 -> birth at 7 of 0-cycle
zp.remove_face(2);
zp.remove_cell(2);

// Only the closed bars were output so far, so the open/infinite bars still need to be retrieved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <gudhi/filtered_zigzag_persistence.h>

using ZP = Gudhi::zigzag_persistence::Filtered_zigzag_persistence_with_storage<>;
using Face_handle = ZP::Face_key;
using Cell_handle = ZP::Cell_key;
using Filtration_value = ZP::Filtration_value;
using Interval_filtration = ZP::Filtration_value_interval;

Expand Down Expand Up @@ -50,7 +50,7 @@ void print_indices(ZP& zp) {
}
}

std::vector<std::vector<Face_handle> > get_boundaries() {
std::vector<std::vector<Cell_handle> > get_boundaries() {
return {{},
{},
{},
Expand Down Expand Up @@ -114,7 +114,7 @@ int main(int argc, char* const argv[]) {

ZP zp;

std::vector<std::vector<Face_handle> > simplices = get_boundaries();
std::vector<std::vector<Cell_handle> > simplices = get_boundaries();
std::vector<Filtration_value> fils = get_filtration_values();
std::vector<bool> dirs = get_directions();

Expand All @@ -125,10 +125,10 @@ int main(int argc, char* const argv[]) {
}
if (dirs[i]) {
int dim = simplices[i].size() == 0 ? 0 : simplices[i].size() - 1;
zp.insert_face(i, simplices[i], dim, fils[i]);
zp.insert_cell(i, simplices[i], dim, fils[i]);
} else {
auto id = simplices[i][0];
zp.remove_face(id, fils[i]);
zp.remove_cell(id, fils[i]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <gudhi/filtered_zigzag_persistence.h>

using ZP = Gudhi::zigzag_persistence::Filtered_zigzag_persistence<>;
using ID_handle = ZP::Face_key;
using ID_handle = ZP::Cell_key;
using Filtration_value = ZP::Filtration_value;
using Dimension = ZP::Dimension;

Expand Down Expand Up @@ -89,7 +89,7 @@ int main(int argc, char* const argv[]) {
while (getline(file, line, '\n') && read_operation(line, data, timestamp) == COMMENT);
double lastTimestamp = timestamp;
// first operation has to be an insertion.
zp.insert_face(id, data, 0, timestamp);
zp.insert_cell(id, data, 0, timestamp);

while (getline(file, line, '\n')) {
type = read_operation(line, data, timestamp);
Expand All @@ -100,10 +100,10 @@ int main(int argc, char* const argv[]) {
if (type == INCLUSION) {
++id;
int dim = data.size() == 0 ? 0 : data.size() - 1;
zp.insert_face(id, data, dim, timestamp);
zp.insert_cell(id, data, dim, timestamp);
} else if (type == REMOVAL) {
++id;
zp.remove_face(data[0], timestamp);
zp.remove_cell(data[0], timestamp);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ struct Simplex_tree_options_oscillating_rips {

template <class StableFilteredComplex>
struct Default_oscillating_rips_zigzag_options : Default_filtered_zigzag_options {
using Face_key = typename StableFilteredComplex::Simplex_handle;
using Cell_key = typename StableFilteredComplex::Simplex_handle;
using Filtration_value = typename StableFilteredComplex::Filtration_value;
using Dimension = int; // it is `int` in the simplex tree
struct Hash {
std::size_t operator()(const Face_key& sh) const {
std::size_t operator()(const Cell_key& sh) const {
return sh->second.key();
}
};
struct KeyEqual {
bool operator()(const Face_key& sh1, const Face_key& sh2) const {
bool operator()(const Cell_key& sh1, const Cell_key& sh2) const {
return sh1->second.key() == sh2->second.key();
}
};
Expand Down Expand Up @@ -154,12 +154,12 @@ void compute_oscillating_rips_persistence(

for (const auto& t : OscillatingRipsSimplexRange::get_iterator_range(start, end, st, maxDim)) {
if (std::get<2>(t))
zp.insert_face(std::get<0>(t),
zp.insert_cell(std::get<0>(t),
st.boundary_simplex_range(std::get<0>(t)),
st.dimension(std::get<0>(t)),
std::get<1>(t));
else
zp.remove_face(std::get<0>(t), std::get<1>(t));
zp.remove_cell(std::get<0>(t), std::get<1>(t));
}

zp.get_current_infinite_intervals([&](Dimension dim, Filtration_value birth) { outStream(dim, birth, Bar::inf); });
Expand Down Expand Up @@ -233,12 +233,12 @@ compute_oscillating_rips_persistence(

for (const auto& t : OscillatingRipsSimplexRange::get_iterator_range(start, end, st, maxDim)) {
if (std::get<2>(t))
zp.insert_face(std::get<0>(t),
zp.insert_cell(std::get<0>(t),
st.boundary_simplex_range(std::get<0>(t)),
st.dimension(std::get<0>(t)),
std::get<1>(t));
else
zp.remove_face(std::get<0>(t), std::get<1>(t));
zp.remove_cell(std::get<0>(t), std::get<1>(t));
}

return zp.get_persistence_diagram();
Expand Down
Loading

0 comments on commit 0655678

Please sign in to comment.