Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigzag persistence part2 #953

Draft
wants to merge 80 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5407637
restore after merge
hschreiber Jul 17, 2023
f03a8bf
Merge remote-tracking branch 'origin/persistence_matrix' into zigzag_…
hschreiber Jul 18, 2023
3f8409f
doc and concepts
hschreiber Jul 21, 2023
2e5a20b
deleting files not wanted for the PR
hschreiber Jul 21, 2023
bfc5642
doc main page
hschreiber Jul 21, 2023
688b381
restore cmake files
hschreiber Jul 21, 2023
f7087fc
restore cmake files
hschreiber Jul 21, 2023
15fbc53
restore cmake files
hschreiber Jul 21, 2023
4f06e5c
rips edge iterator
hschreiber Jul 28, 2023
9eb1e01
Merge remote-tracking branch 'origin/simplex_tree_zigzag_option' into…
hschreiber Aug 1, 2023
87ba652
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Aug 4, 2023
0dcf241
Merge remote-tracking branch 'origin/stable_simplex_handles' into osc…
hschreiber Aug 4, 2023
5e530f7
oscillating rips range
hschreiber Aug 4, 2023
40bb36a
Merge remote-tracking branch 'origin/persistence_matrix' into oscilla…
hschreiber Aug 7, 2023
9b0a7cc
oscillating rips persistence, example and benchmark
hschreiber Aug 8, 2023
63aad6a
doc
hschreiber Aug 9, 2023
d8d07c5
simplex tree options correction
hschreiber Aug 21, 2023
0644ca6
sync with upstream Gudhi-devel
hschreiber Aug 21, 2023
394e33e
doc
hschreiber Aug 21, 2023
951cbb8
doc
hschreiber Aug 21, 2023
7178d45
first update merge
hschreiber Aug 21, 2023
5c4f9d7
second update merge
hschreiber Aug 21, 2023
2c79bc2
merge error fix
hschreiber Aug 21, 2023
f85ffb9
removal of useless simplex tree options
hschreiber Aug 21, 2023
d63e697
merge updated upstream
hschreiber Aug 21, 2023
b640b89
Merge branch 'GUDHI:master' into oscillating_rips
hschreiber Aug 22, 2023
902db3b
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Aug 22, 2023
52376df
Merge branch 'GUDHI:master' into oscillating_rips
hschreiber Aug 25, 2023
8f2dc9c
doc
hschreiber Aug 31, 2023
67637b9
cleanup
hschreiber Aug 31, 2023
ba7ee4d
merge upstream
hschreiber Sep 1, 2023
da925a0
update from upstream master
hschreiber Apr 18, 2024
5208e5d
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Apr 18, 2024
4436039
update persistence matrix
hschreiber Apr 19, 2024
e384378
update persistence matrix
hschreiber Apr 19, 2024
0c7d3e6
generalized to faces instead of simplices
hschreiber May 31, 2024
ece1294
updates concepts
hschreiber May 31, 2024
20ae249
updates concepts
hschreiber May 31, 2024
df39f9c
zigzag doc update
hschreiber May 31, 2024
c192cd6
merge upstream update
hschreiber May 31, 2024
cadfb5c
merge Persistence_matrix update
hschreiber May 31, 2024
03e7b7d
small fixes
hschreiber May 31, 2024
26161a7
persistence diagram: list -> vector
hschreiber May 31, 2024
9c44409
removal of useless abs
hschreiber May 31, 2024
3fb6227
merge upstream
hschreiber Jun 18, 2024
2b46f13
split of zigzag computation and filtration values management
hschreiber Jun 20, 2024
dcc8bad
Merge remote-tracking branch 'origin/persistence_matrix' into zigzag_…
hschreiber Jun 20, 2024
dfdaaac
change of default values
hschreiber Jun 21, 2024
f7a431b
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Jun 27, 2024
8698036
Merge branch 'zigzag_persistence' of github.com:hschreiber/gudhi-deve…
hschreiber Jun 27, 2024
91dca3b
Merge remote-tracking branch 'origin/matrix_intervals' into zigzag_pe…
hschreiber Jun 28, 2024
e51a1f3
change of barcode + minor corrections
hschreiber Jun 28, 2024
585432c
update example cmake
hschreiber Jun 28, 2024
55d510a
rename files to gudhi convention
hschreiber Jul 8, 2024
0c332e3
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Jul 8, 2024
bf19ed5
fix version problem with boost::unordered_flat_map
hschreiber Jul 9, 2024
46a7d8a
Merge remote-tracking branch 'origin/master' into zigzag_persistence
hschreiber Jul 10, 2024
c42a263
corrections from merge with upstream
hschreiber Jul 10, 2024
efa2546
remove doxygen warnings
hschreiber Jul 11, 2024
cfdc161
dox fix
hschreiber Jul 11, 2024
e025cec
doc fix
hschreiber Jul 11, 2024
99f99ae
small changes
hschreiber Jul 18, 2024
6dc4219
Update src/Zigzag_persistence/include/gudhi/zigzag_persistence.h
hschreiber Jul 18, 2024
9446bad
Update src/Zigzag_persistence/include/gudhi/zigzag_persistence.h
hschreiber Jul 18, 2024
32e3053
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Jul 18, 2024
bbd3d90
doc
hschreiber Jul 19, 2024
c7edb91
replacing map_index_to_filtration_value->pair with get_filtration_val…
hschreiber Jul 19, 2024
3472160
doc
hschreiber Jul 19, 2024
744ac47
dim bug fix
hschreiber Jul 22, 2024
7d84dbf
doc
hschreiber Jul 22, 2024
564f751
doc
hschreiber Jul 22, 2024
bd6d9b5
doc
hschreiber Jul 23, 2024
4de6a26
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Sep 17, 2024
4f40d8b
upstream merge
hschreiber Sep 17, 2024
6a0fad2
renaming after Gudhi convention
hschreiber Sep 17, 2024
2b2a569
doc
hschreiber Sep 17, 2024
1e31a4b
doc
hschreiber Sep 18, 2024
f0978fc
merge upstream
hschreiber Sep 19, 2024
d8a8273
name fix
hschreiber Sep 24, 2024
da86ef5
add std:: to size_t
hschreiber Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ add_gudhi_module(Toplex_map)
add_gudhi_module(Witness_complex)
add_gudhi_module(Nerve_GIC)
add_gudhi_module(Persistence_matrix)
add_gudhi_module(Zigzag_persistence)

# Include module CMake subdirectories
# GUDHI_SUB_DIRECTORIES is managed in CMAKE_MODULE_PATH/GUDHI_modules.cmake
Expand Down
12 changes: 12 additions & 0 deletions biblio/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ @book{Munkres-elementsalgtop1984
bibsource = {DBLP, http://dblp.uni-trier.de}
}

@inproceedings{osc_zz,
author = {Oudot, Steve and Sheehy, Donald},
year = {2013},
month = {06},
pages = {387-396},
title = {{Zigzag Zoology: Rips Zigzags for Homology Inference}},
volume = {15},
booktitle = {Foundations of Computational Mathematics},
url = {https://doi.org/10.1145/2462356.2462371},
doi = {10.1145/2462356.2462371}
}

@article{Cohen-Steiner2009,
author = {Cohen-Steiner, David and Edelsbrunner, Herbert and Harer, John},
journal = {Foundations of Computational Mathematics},
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_gudhi_module(Toplex_map)
add_gudhi_module(Witness_complex)
add_gudhi_module(Nerve_GIC)
add_gudhi_module(Persistence_matrix)
add_gudhi_module(Zigzag_persistence)

set(GUDHI_BIBLIO_DIR ${CMAKE_SOURCE_DIR})
# For "make doxygen" - Requires GUDHI_USER_VERSION_DIR to be set
Expand Down
31 changes: 31 additions & 0 deletions src/Zigzag_persistence/concept/DistanceFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#ifndef CONCEPT_ZZ_DISTANCE_FUNCTION_H_
#define CONCEPT_ZZ_DISTANCE_FUNCTION_H_

/** @file DistanceFunction.h
* @brief Contains @ref Gudhi::zigzag_persistence::DistanceFunction concept.
*/

#include "PointRange.h"

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Distance function taking two points as input and returning the distance between them.
*/
using DistanceFunction = double (*)(const Point&, const Point&);

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_DISTANCE_FUNCTION_H_
54 changes: 54 additions & 0 deletions src/Zigzag_persistence/concept/EdgeModifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#ifndef CONCEPT_ZZ_EDGE_MODIFIER_H_
#define CONCEPT_ZZ_EDGE_MODIFIER_H_

/** @file EdgeModifier.h
* @brief Contains @ref Gudhi::zigzag_persistence::EdgeModifier concept.
*/

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Methods whose purposes are to modify the filtration value of a given edge following a rule.
* The concept is for example realized by @ref Square_root_edge_modifier.
*/
template <typename Filtration_value>
class EdgeModifier {
public:
/**
* @brief Indicates that the modifier should not be ignored.
*/
static constexpr bool isActive_ = true;

/**
* @brief Applies the modifier to the given value and returns it.
*
* @param f Value to modify.
* @return The modified value of @p f.
*/
static Filtration_value apply_modifier(Filtration_value f);

/**
* @brief Applies the inverse modifier to the given value and returns it.
* So, apply_inverse_modifier(apply_modifier(f)) == f (modulo some possible precision errors.).
*
* @param f Value to modify.
* @return The modified value of @p f.
*/
static Filtration_value apply_inverse_modifier(Filtration_value f);
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_EDGE_MODIFIER_H_
69 changes: 69 additions & 0 deletions src/Zigzag_persistence/concept/OscillatingRipsSimplexRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#ifndef CONCEPT_ZZ_OSCI_RIPS_RANGE_H_
#define CONCEPT_ZZ_OSCI_RIPS_RANGE_H_

/** @file OscillatingRipsSimplexRange.h
* @brief Contains @ref Gudhi::zigzag_persistence::OscillatingRipsSimplexRange concept.
*/

#include <gudhi/Zigzag_persistence/oscillating_rips_iterators.h>
#include <gudhi/Simplex_tree.h>

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Class giving access to a range over the simplices in an oscillating Rips filtration
* in order of the filtration.
*
* A simplex has to be represented by a tuple of three elements:
* the first is the simplex handle of the simplex in the given complex,
* the second is the filtration value of the corresponding arrow,
* the third is the direction of the arrow, i.e., indicates if the simplex is inserted or removed.
*/
class OscillatingRipsSimplexRange {
public:
/**
* @brief Returns a range over the simplices in an oscillating Rips filtration
* in order of the filtration.
*
* @param edgeStartIterator Begin iterator of the edge range.
* @param edgeEndIterator End iterator of the edge range.
* @param complex Structure storing the complex at each step.
* @param maxDimension Maximal dimension of the expansion.
* @return A range with begin() and end() methods.
*/
static auto get_iterator_range(Oscillating_rips_edge_range<double>::Oscillating_rips_edge_iterator& edgeStartIterator,
Oscillating_rips_edge_range<double>::Oscillating_rips_edge_iterator& edgeEndIterator,
StableFilteredComplex& complex,
int maxDimension);

/**
* @brief Returns a range over the simplices in an oscillating Rips filtration
* in order of the filtration.
*
* @param edgeStartIterator Begin iterator of the edge range.
* @param edgeEndIterator End iterator of the edge range.
* @param complex Structure storing the complex at each step.
* @param maxDimension Maximal dimension of the expansion.
* @return A range with begin() and end() methods.
*/
static auto get_iterator_range(std::vector<Zigzag_edge<double> >::iterator& edgeStartIterator,
std::vector<Zigzag_edge<double> >::iterator& edgeEndIterator,
StableFilteredComplex& complex,
int maxDimension);
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_OSCI_RIPS_RANGE_H_
67 changes: 67 additions & 0 deletions src/Zigzag_persistence/concept/PointRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#ifndef CONCEPT_ZZ_POINT_RANGE_H_
#define CONCEPT_ZZ_POINT_RANGE_H_

/** @file PointRange.h
* @brief Contains @ref Gudhi::zigzag_persistence::Point and @ref Gudhi::zigzag_persistence::PointRange concept.
*/

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Data structure representing a point of fixed dimension. The structure of the point does not matter
* it-self as long as it corresponds to the input type of the @ref DistanceFunction concept.
*/
class Point{};

/**
* @brief Range of @ref Point. Used with @ref Oscillating_rips_edge_range::Order_policy::FARTHEST_POINT_ORDERING order policy,
* it has to be a random access range.
*/
class PointRange {
public:
/**
* @brief Returns begin iterator.
*
* @return Begin iterator.
*/
auto begin();

/**
* @brief Returns end iterator.
*
* @return End iterator.
*/
auto end();

/**
* @brief Returns size of the range.
*
* @return Size of the range.
*/
std::size_t size();

/**
* @brief Necessary only if used with @ref Oscillating_rips_edge_range::Order_policy::FARTHEST_POINT_ORDERING. Returns the element
* at the given index.
*
* @param index Index of the element to return.
* @return Point at index @p index.
*/
Point operator[](std::size_t index);
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_POINT_RANGE_H_
121 changes: 121 additions & 0 deletions src/Zigzag_persistence/concept/StableFilteredComplex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hannah Schreiber
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#ifndef CONCEPT_ZZ_STABLE_COMPLEX_TYPE_H_
#define CONCEPT_ZZ_STABLE_COMPLEX_TYPE_H_

/** @file StableFilteredComplex.h
* @brief Contains @ref Gudhi::zigzag_persistence::StableFilteredComplex concept.
*/

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Data structure storing the simplices and their filtration values in the current complex.
* The concept is realized for example by @ref Gudhi::Simplex_tree < Gudhi::Simplex_tree_options_oscillating_rips >.
*
* This concept is not incompatible with the @ref ZigzagComplex concept, so it is possible to use the same complex
* for the @ref Oscillating_rips_iterator class and the @ref ZigzagPersistence class, as long as it realizes the two
* concepts (which is the case for @ref Gudhi::Simplex_tree < Gudhi::Simplex_tree_options_oscillating_rips >).
* This avoids having two complexes in memory and give the possibility to directly use the simplex handle instead
* of the vector of vertices to communicate between the two classes.
*/
class StableFilteredComplex {
public:
/**
* @brief Integer type that needs to be long enough to store the numbers of arrows in the zigzag filtration.
*/
typename Simplex_key;

/**
* @brief Handle to specify a simplex. Different from the @ref ZigzagComplex concept,
* the simplex handles have to be stable, that is, they do not invalidate when a simplex is
* added or removed from the complex (except for the removed simplices them selves of course).
*/
typename Simplex_handle;

/**
* @brief Type for filtration values. Usually 'double'.
*/
typename Filtration_value;

/**
* @brief Removes the given simplex. Assumes that the simplex is maximal and can be safely removed.
*
* @param sh Simplex handle representing the simplex to remove.
*/
void remove_maximal_simplex(Simplex_handle sh);

/**
* @brief Adds a vertex or an edge in a flag complex, as well as all
* simplices of its star, defined to maintain the property
* of the complex to be a flag complex, truncated at dimension dim_max.
*
* @param u ID of one end of the edge.
* @param v ID of the other end of the edge. If @p u == @p v, then the input is considered as a vertex.
* @param fil Filtration value of the edge.
* @param dim_max Maximal dimension of the expansion. If set to -1, the expansion goes as far as possible.
* @param added_simplices Container for all new simplices induced by the insertion of the edge.
* If not empty at start, the content of the container should @b not be erased by the method.
*/
void insert_edge_as_flag(int u,
int v,
Filtration_value fil,
int dim_max,
std::vector<Simplex_handle>& added_simplices);

/**
* @brief Returns the key associated to the given simplex.
*
* @param sh Simplex handle representing the simplex.
* @return The key.
*/
Simplex_key key(Simplex_handle sh);

/**
* @brief Assignes the given value to the given simplex as a key.
*
* @param sh Simplex handle representing the simplex.
* @param key Values to associate as key.
*/
void assign_key(Simplex_handle sh, Simplex_key key);

/**
* @brief Finds the given simplex in the complex and returns the associated simplex handle.
*
* @tparam VertexRange Range over the vertices of a simplex.
* @param simplex Simplex to find represented by its vertices.
* @return The simplex handle associated to @p simplex if the simplex is found, @ref null_simplex() otherwise.
*/
template <class VertexRange>
Simplex_handle find(const VertexRange& simplex);

/**
* @brief Returns the filtration value of the given simplex.
*
* @param sh
* @return Filtration_value
*/
Filtration_value filtration(Simplex_handle sh);

/**
* @brief Returns a range (with begin() and end() methods) over the star of the given simplex, including the simplex.
*
* @param simplex Simplex to compute the star from.
* @return A iterable range over the star of @p simplex.
*/
auto star_simplex_range(const Simplex_handle simplex);
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_STABLE_COMPLEX_TYPE_H_
Loading
Loading