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 part1 #917

Merged
merged 69 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
69 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
87ba652
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Aug 4, 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
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
902db3b
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Aug 22, 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
54c00a6
Merge branch 'GUDHI:master' into zigzag_persistence
hschreiber Oct 21, 2024
5db9b3a
name change from 'face' to 'cell'
hschreiber Oct 21, 2024
915b5ea
removal of 'erase_birth_history'
hschreiber Oct 21, 2024
b3158e3
replacing set with vector for boundary translation
hschreiber Oct 22, 2024
5213928
Update src/common/doc/main_page.md
hschreiber Oct 24, 2024
f4c5345
Update src/Zigzag_persistence/doc/COPYRIGHT
hschreiber Oct 24, 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
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)

# For "make doxygen" - Requires GUDHI_USER_VERSION_DIR to be set
set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR})
Expand Down
128 changes: 128 additions & 0 deletions src/Zigzag_persistence/concept/ZigzagComplex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* 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_COMPLEX_TYPE_H_
#define CONCEPT_ZZ_COMPLEX_TYPE_H_

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

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief Data structure storing the simplices in the current complex.
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
*/
class ZigzagComplex {
public:
/**
* @brief Signed 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.
*/
typename Simplex_handle;

/**
* @brief Handle to specify a vertex. Should be an integer type.
*/
typename Vertex_handle;

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

/**
* @brief Range of simplex handles over the boundary of a simplex
*/
typename Boundary_simplex_range;

/**
* @brief Constructor
*/
ZigzagComplex();

/**
* @brief Inserts the given simplex in the complex.
*
* @tparam VertexRange Range over the vertices of a simplex.
* @param simplex Simplex to insert represented by its vertices.
* @return A pair of a simplex handle and a boolean.
* The simplex handle represents the inserted simplex and
* the boolean if simplex was already contained in the complex or not.
*/
template <class VertexRange>
std::pair<Simplex_handle, bool> insert_simplex(const VertexRange& simplex);

/**
* @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 Returns the dimension of the given simplex.
*
* @param sh Simplex handle representing the simplex.
* @return Dimension of @a sh.
*/
int dimension(Simplex_handle sh);

/**
* @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 @a simplex if the simplex is found, @ref null_simplex() otherwise.
*/
template <class VertexRange>
Simplex_handle find(const VertexRange& simplex);

/**
* @brief Returns a range of simplex handles representing the boundary of the given simplex.
*
* @param sh Simplex handle representing the simplex.
* @return Range of simplex handles.
*/
Boundary_simplex_range boundary_simplex_range(Simplex_handle sh);

/**
* @brief Returns a simplex handle representing a non existing simplex.
*
* @return A simplex handle.
*/
Simplex_handle null_simplex();
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_COMPLEX_TYPE_H_
90 changes: 90 additions & 0 deletions src/Zigzag_persistence/concept/ZigzagPersistenceOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* 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_OPTIONS_TYPE_H_
#define CONCEPT_ZZ_OPTIONS_TYPE_H_

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

namespace Gudhi {
namespace zigzag_persistence {

/**
* @brief List of options used for the matrix maintained for the zigzag persistence computation.
*/
struct ZigzagPersistenceOptions {
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
/**
* @brief Type for the coefficient field type. Has to support \f$Z_2\f$.
*/
typename field_coeff_type;

/**
* @brief Has to be set to true. Indicates that the computation will be made with \f$Z_2\f$ coefficients.
*/
static const bool is_z2 = true;
/**
* @brief Type of the columns in the matrix.
* The available column types are given by @ref Gudhi::persistence_matrix::Column_types.
* The column type has to support row access.
*/
static const Column_types column_type;

/**
* @brief Has to be set to true. Indicates that the rows should be directly accessible in the matrix.
*/
static const bool has_row_access = true;
/**
* @brief Set to true, if the rows should be intrusive lists or to false if they should be sets. True is recommended.
* Note that intrusive rows are not compatible with certain column types.
*/
static const bool has_intrusive_rows;
/**
* @brief Has to set to true. Indicates that the rows of the matrix can be removed.
*/
static const bool has_removable_rows = true;
/**
* @brief Has to be set to false. Indicates that the matrix should not store birth/death pairs of its columns.
*/
static const bool has_column_pairings = false;
/**
* @brief Has to be set to true. Enables maintaining the matrix while switching columns.
*/
static const bool has_vine_update = true;
/**
* @brief If set to true, the matrix can retrieve the representative cycles for the cycle classes.
* This option is useless for zigzag computation and therefore it is recommended to set it to false.
*/
static const bool can_retrieve_representative_cycles;
/**
* @brief This value has to be defined but will be ignored.
*/
static const bool has_column_compression;
/**
* @brief Has to be set to false.
* Indicates that the matrix should represent the base of the chain complex and not of the boundary group.
*/
static const bool is_of_boundary_type = false;
/**
* @brief Has to be set to true. Indicates that the columns of the matrix can be removed.
*/
static const bool has_removable_columns = true;
/**
* @brief Has to be set to false.
* Indicates that the access to the columns will be done through simplex IDs instead of column positions.
*/
static const bool is_indexed_by_position = false;
};

} // namespace zigzag_persistence
} // namespace Gudhi

#endif // CONCEPT_ZZ_OPTIONS_TYPE_H_
12 changes: 12 additions & 0 deletions src/Zigzag_persistence/doc/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The files of this directory are part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentRouvreau Can you remind me why we have this file in every doc/ subdirectory? Is it because there are images, where we cannot include the text? And having some global statement somewhere would have been complicated because of exceptions?

See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.

Author(s): Vincent Rouvreau

Copyright (C) 2015 Inria
hschreiber marked this conversation as resolved.
Show resolved Hide resolved

This gives everyone the freedoms to use openFrameworks in any context:
commercial or non-commercial, public or private, open or closed source.

You should have received a copy of the MIT License along with this program.
If not, see https://opensource.org/licenses/MIT.
52 changes: 52 additions & 0 deletions src/Zigzag_persistence/doc/Intro_zigzag_persistence.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* 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 DOC_ZIGZAG_PERSISTENCE_INTRO_ZIGZAG_PERSISTENCE_H_
#define DOC_ZIGZAG_PERSISTENCE_INTRO_ZIGZAG_PERSISTENCE_H_

// needs namespace for Doxygen to link on classes
namespace Gudhi {
namespace zigzag_persistence {

/** \defgroup zigzag_persistence Zigzag Persistence
* @{
* \author Cl&eacute;ment Maria, Hannah Schreiber
*
* We refer to the introduction page \ref persistent_cohomology for persistent (co)homology for an introduction
* to the topic.
* Zigzag persistence is a generalization of the latter. While standard persistence only allows to grow the filtered
* complex by adding simplices, zigzag persistence also allows removals. Hence the name "zigzag", as the module
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
* diagram will have arrows alterning between forward and backward.
*
* The implementation is based on the algorithm introduced in \cite zigzag.
*
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
* \subsection zigzaginterface Stream-like interface
mglisse marked this conversation as resolved.
Show resolved Hide resolved
*
* As removals are possible in zigzag filtration, the maximal size of the complex does not depend on the length of the
* filtration anymore. This makes it possible to build very long fine tuned filtrations with relatively small complexes
* which can be processed without overreaching memory space. For this purpose, it is possible to feed the module with
* information about the filtration "on the fly" to avoid loading the whole filtration at once. Information about the
* current complex and current barcode can be retrieved between any steps.
mglisse marked this conversation as resolved.
Show resolved Hide resolved
*
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
* \subsection zigzagexamples Examples
*
* Here is a list of zigzag persistence examples :
* \li \gudhi_example_link{Zigzag_persistence,example_simple_zigzag_filtration.cpp} - A simple example to showcase how
* to use the \ref Zigzag_persistence class.
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
*
* \li \gudhi_example_link{Zigzag_persistence,example_zzfiltration_from_file.cpp} - An example of a "stream-like" usage
* by reading of the filtration from a file.
*
* @}
*/
} // namespace zigzag_persistence
} // namespace Gudhi

#endif // DOC_ZIGZAG_PERSISTENCE_INTRO_ZIGZAG_PERSISTENCE_H_
Binary file added src/Zigzag_persistence/doc/zigzag_ex.png
hschreiber marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/Zigzag_persistence/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project(Zigzag_persistence_examples)

add_executable ( Zigzag_persistence_example_simple_zigzag_filtration example_simple_zigzag_filtration.cpp )
if(TARGET TBB::tbb)
target_link_libraries(Zigzag_persistence_example_simple_zigzag_filtration TBB::tbb)
endif()
add_test(NAME Zigzag_persistence_example_simple_zigzag_filtration COMMAND $<TARGET_FILE:Zigzag_persistence_example_simple_zigzag_filtration>)

add_executable ( Zigzag_persistence_example_zzfiltration_from_file example_zzfiltration_from_file.cpp )
if(TARGET TBB::tbb)
target_link_libraries(Zigzag_persistence_example_zzfiltration_from_file TBB::tbb)
endif()
file(COPY "zigzag_filtration_example.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
add_test(NAME Zigzag_persistence_example_zzfiltration_from_file COMMAND $<TARGET_FILE:Zigzag_persistence_example_zzfiltration_from_file> "${CMAKE_CURRENT_BINARY_DIR}/zigzag_filtration_example.txt")




Loading
Loading