summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-02 15:45:06 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-02 15:45:06 +0000
commit5ae31a73253f6b29f5cbf1e04af17acf62741d9e (patch)
tree512041b9bf0835f2520e5b6b2fde0f972998efc4 /src/Persistent_cohomology
parent4a5332dfb88ec27157c82f77df87f588f7016736 (diff)
parent265484997185f3bf900744406206a2d64ca0a20d (diff)
Merge last trunk modificat
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3212 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ea6296547b67ad82f5983d4309493e9131da7dd0
Diffstat (limited to 'src/Persistent_cohomology')
-rw-r--r--src/Persistent_cohomology/doc/Intro_persistent_cohomology.h73
-rw-r--r--src/Persistent_cohomology/example/CMakeLists.txt80
-rw-r--r--src/Persistent_cohomology/example/README121
-rw-r--r--src/Persistent_cohomology/example/alpha_complex_3d_helper.h76
-rw-r--r--src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp235
-rw-r--r--src/Persistent_cohomology/example/alpha_complex_persistence.cpp125
-rw-r--r--src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp237
-rw-r--r--src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp257
-rw-r--r--src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp144
-rw-r--r--src/Persistent_cohomology/example/rips_persistence.cpp147
-rw-r--r--src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp59
-rw-r--r--src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp282
-rw-r--r--src/Persistent_cohomology/example/weighted_periodic_alpha_complex_3d_persistence.cpp281
13 files changed, 56 insertions, 2061 deletions
diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
index 1b8ff95a..4dbe82c7 100644
--- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
+++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
@@ -143,8 +143,8 @@ namespace persistent_cohomology {
We provide several example files: run these examples with -h for details on their use, and read the README file.
-\li <a href="_persistent_cohomology_2rips_persistence_8cpp-example.html">
-Persistent_cohomology/rips_persistence.cpp</a> computes the Rips complex of a point cloud and outputs its persistence
+\li <a href="_rips_complex_2rips_persistence_8cpp-example.html">
+Rips_complex/rips_persistence.cpp</a> computes the Rips complex of a point cloud and outputs its persistence
diagram.
\code $> ./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 \endcode
\code The complex contains 177838 simplices
@@ -158,57 +158,44 @@ diagram.
Persistent_cohomology/rips_multifield_persistence.cpp</a> computes the Rips complex of a point cloud and outputs its
persistence diagram with a family of field coefficients.
-\li <a href="_persistent_cohomology_2rips_distance_matrix_persistence_8cpp-example.html">
-Persistent_cohomology/rips_distance_matrix_persistence.cpp</a> computes the Rips complex of a distance matrix and
+\li <a href="_rips_complex_2rips_distance_matrix_persistence_8cpp-example.html">
+Rips_complex/rips_distance_matrix_persistence.cpp</a> computes the Rips complex of a distance matrix and
outputs its persistence diagram.
-The file should contain square or lower triangular distance matrix with semicolons as separators.
-The code do not check if it is dealing with a distance matrix. It is the user responsibility to provide a valid input.
-Please refer to data/distance_matrix/lower_triangular_distance_matrix.csv for an example of a file.
-
-\li <a href="_persistent_cohomology_2rips_correlation_matrix_persistence_8cpp-example.html">
-Persistent_cohomology/rips_correlation_matrix_persistence.cpp</a>
-computes the Rips complex of a correlation matrix and outputs its persistence diagram.
-
-Note that no check is performed if the matrix given as the input is a correlation matrix.
-It is the user responsibility to ensure that this is the case. The input is to be given either as a square or a lower
-triangular matrix.
-Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv for an example of a file.
-
-\li <a href="_persistent_cohomology_2alpha_complex_3d_persistence_8cpp-example.html">
-Persistent_cohomology/alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html">
+Alpha_complex/alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file.
-\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45 \endcode
+\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 \endcode
\code Simplex_tree dim: 3
2 0 0 inf
2 1 0.0682162 1.0001
2 1 0.0934117 1.00003
2 2 0.56444 1.03938 \endcode
-\li <a href="_persistent_cohomology_2exact_alpha_complex_3d_persistence_8cpp-example.html">
-Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\li <a href="_alpha_complex_2exact_alpha_complex_3d_persistence_8cpp-example.html">
+Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file.
Here, as CGAL computes the exact values, it is slower, but it is necessary when points are on a grid
for instance.
-\code $> ./exact_alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off 2 0.1 \endcode
+\code $> ./exact_alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off -p 2 -m 0.1 \endcode
\code Simplex_tree dim: 3
2 0 0 inf
2 2 0.0002 0.2028 \endcode
-\li <a href="_persistent_cohomology_2weighted_alpha_complex_3d_persistence_8cpp-example.html">
-Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\li <a href="_alpha_complex_2weighted_alpha_complex_3d_persistence_8cpp-example.html">
+Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the weighted alpha complex on points sampling from an OFF file
and a weights file.
\code $> ./weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off
-../../data/points/tore3D_300.weights 2 0.45 \endcode
+../../data/points/tore3D_300.weights -p 2 -m 0.45 \endcode
\code Simplex_tree dim: 3
2 0 -1 inf
2 1 -0.931784 0.000103311
2 1 -0.906588 2.60165e-05
2 2 -0.43556 0.0393798 \endcode
-\li <a href="_persistent_cohomology_2alpha_complex_persistence_8cpp-example.html">
-Persistent_cohomology/alpha_complex_persistence.cpp</a> computes the persistent homology with
+\li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html">
+Alpha_complex/alpha_complex_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file.
\code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode
\code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices.
@@ -218,11 +205,13 @@ Simplex_tree dim: 3
2 1 0.0934117 1.00003
2 2 0.56444 1.03938 \endcode
-\li <a href="_persistent_cohomology_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
-Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
+Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file.
+The second parameter is a \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid.
+Note that the lengths of the sides of the periodic cuboid have to be the same.
\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off
-../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0 \endcode
+../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 \endcode
\code Periodic Delaunay computed.
Simplex_tree dim: 3
3 0 0 inf
@@ -234,11 +223,31 @@ Simplex_tree dim: 3
3 2 0.005 inf
3 3 0.0075 inf \endcode
+\li <a href="_persistent_cohomology_2weighted_periodic_alpha_complex_3d_persistence_8cpp-example.html">
+Persistent_cohomology/weighted_periodic_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on weighted points from an OFF file. The
+additional parameters of this program are:<br>
+(a) The file with the weights of points. The file consist of a sequence of numbers (as many as points).
+Note that the weight of each single point have to be bounded by 1/64 times the square of the cuboid edge length.<br>
+(b) A \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid.
+Note that the lengths of the sides of the periodic cuboid have to be the same.<br>
+\code $> ./weighted_periodic_alpha_complex_3d_persistence ../../data/points/shifted_sphere.off
+../../data/points/shifted_sphere.weights ../../data/points/iso_cuboid_3_in_0_10.txt 3 1.0 \endcode
+\code Weighted Periodic Delaunay computed.
+Simplex_tree dim: 3
+3 0 -0.0001 inf
+3 1 16.0264 inf
+3 1 16.0273 inf
+3 1 16.0303 inf
+3 2 36.8635 inf
+3 2 36.8704 inf
+3 2 36.8838 inf
+3 3 58.6783 inf \endcode
+
\li <a href="_persistent_cohomology_2plain_homology_8cpp-example.html">
Persistent_cohomology/plain_homology.cpp</a> computes the plain homology of a simple simplicial complex without
filtration values.
- \copyright GNU General Public License v3.
*/
} // namespace persistent_cohomology
diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt
index 80e5647d..18e2913b 100644
--- a/src/Persistent_cohomology/example/CMakeLists.txt
+++ b/src/Persistent_cohomology/example/CMakeLists.txt
@@ -5,15 +5,6 @@ add_executable(plain_homology plain_homology.cpp)
add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp)
-add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp)
-target_link_libraries(rips_distance_matrix_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
-add_executable(rips_correlation_matrix_persistence rips_correlation_matrix_persistence.cpp)
-target_link_libraries(rips_correlation_matrix_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
-add_executable(rips_persistence rips_persistence.cpp)
-target_link_libraries(rips_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
add_executable(rips_persistence_step_by_step rips_persistence_step_by_step.cpp)
target_link_libraries(rips_persistence_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY})
@@ -26,9 +17,6 @@ target_link_libraries(persistence_from_file ${Boost_PROGRAM_OPTIONS_LIBRARY})
if (TBB_FOUND)
target_link_libraries(plain_homology ${TBB_LIBRARIES})
target_link_libraries(persistence_from_simple_simplex_tree ${TBB_LIBRARIES})
- target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES})
- target_link_libraries(rips_correlation_matrix_persistence ${TBB_LIBRARIES})
- target_link_libraries(rips_persistence ${TBB_LIBRARIES})
target_link_libraries(rips_persistence_step_by_step ${TBB_LIBRARIES})
target_link_libraries(rips_persistence_via_boundary_matrix ${TBB_LIBRARIES})
target_link_libraries(persistence_from_file ${TBB_LIBRARIES})
@@ -37,12 +25,6 @@ endif()
add_test(NAME Persistent_cohomology_example_plain_homology COMMAND $<TARGET_FILE:plain_homology>)
add_test(NAME Persistent_cohomology_example_from_simple_simplex_tree COMMAND $<TARGET_FILE:persistence_from_simple_simplex_tree>
"1" "0")
-add_test(NAME Persistent_cohomology_example_from_rips_distance_matrix COMMAND $<TARGET_FILE:rips_distance_matrix_persistence>
- "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" "-r" "1.0" "-d" "3" "-p" "3" "-m" "0")
-add_test(NAME Persistent_cohomology_example_from_rips_correlation_matrix COMMAND $<TARGET_FILE:rips_correlation_matrix_persistence>
- "${CMAKE_SOURCE_DIR}/data/correlation_matrix/lower_triangular_correlation_matrix.csv" "-c" "0.3" "-d" "3" "-p" "3" "-m" "0")
-add_test(NAME Persistent_cohomology_example_from_rips_on_tore_3D COMMAND $<TARGET_FILE:rips_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3")
add_test(NAME Persistent_cohomology_example_from_rips_step_by_step_on_tore_3D COMMAND $<TARGET_FILE:rips_persistence_step_by_step>
"${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3")
add_test(NAME Persistent_cohomology_example_via_boundary_matrix COMMAND $<TARGET_FILE:rips_persistence_via_boundary_matrix>
@@ -54,9 +36,6 @@ add_test(NAME Persistent_cohomology_example_from_file_3_3_100 COMMAND $<TARGET_F
install(TARGETS plain_homology DESTINATION bin)
install(TARGETS persistence_from_simple_simplex_tree DESTINATION bin)
-install(TARGETS rips_distance_matrix_persistence DESTINATION bin)
-install(TARGETS rips_correlation_matrix_persistence DESTINATION bin)
-install(TARGETS rips_persistence DESTINATION bin)
install(TARGETS rips_persistence_step_by_step DESTINATION bin)
install(TARGETS rips_persistence_via_boundary_matrix DESTINATION bin)
install(TARGETS persistence_from_file DESTINATION bin)
@@ -76,75 +55,16 @@ if(GMP_FOUND)
endif(GMP_FOUND)
if(CGAL_FOUND)
- add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp)
- target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY})
- add_executable(exact_alpha_complex_3d_persistence exact_alpha_complex_3d_persistence.cpp)
- target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY})
-
- if (TBB_FOUND)
- target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES})
- target_link_libraries(exact_alpha_complex_3d_persistence ${TBB_LIBRARIES})
- endif(TBB_FOUND)
- add_test(NAME Persistent_cohomology_example_alpha_complex_3d COMMAND $<TARGET_FILE:alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "2" "0.45")
- add_test(NAME Persistent_cohomology_example_exact_alpha_complex_3d COMMAND $<TARGET_FILE:exact_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "2" "0.45")
-
- install(TARGETS alpha_complex_3d_persistence DESTINATION bin)
- install(TARGETS exact_alpha_complex_3d_persistence DESTINATION bin)
-
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
- add_executable (alpha_complex_persistence alpha_complex_persistence.cpp)
- target_link_libraries(alpha_complex_persistence
- ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
-
- add_executable(periodic_alpha_complex_3d_persistence periodic_alpha_complex_3d_persistence.cpp)
- target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY})
-
add_executable(custom_persistence_sort custom_persistence_sort.cpp)
target_link_libraries(custom_persistence_sort ${CGAL_LIBRARY})
if (TBB_FOUND)
- target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES})
- target_link_libraries(periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
target_link_libraries(custom_persistence_sort ${TBB_LIBRARIES})
endif(TBB_FOUND)
- add_test(NAME Persistent_cohomology_example_alpha_complex COMMAND $<TARGET_FILE:alpha_complex_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45")
- add_test(NAME Persistent_cohomology_example_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:periodic_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "3" "1.0")
add_test(NAME Persistent_cohomology_example_custom_persistence_sort COMMAND $<TARGET_FILE:custom_persistence_sort>)
- install(TARGETS alpha_complex_persistence DESTINATION bin)
- install(TARGETS periodic_alpha_complex_3d_persistence DESTINATION bin)
install(TARGETS custom_persistence_sort DESTINATION bin)
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
-
- if (NOT CGAL_VERSION VERSION_LESS 4.11.0)
- add_executable(weighted_periodic_alpha_complex_3d_persistence weighted_periodic_alpha_complex_3d_persistence.cpp)
- target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY})
- if (TBB_FOUND)
- target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
- endif(TBB_FOUND)
-
- add_test(NAME Persistent_cohomology_example_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
- "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "3" "1.0")
-
- install(TARGETS weighted_periodic_alpha_complex_3d_persistence DESTINATION bin)
-
- endif (NOT CGAL_VERSION VERSION_LESS 4.11.0)
-
- add_executable(weighted_alpha_complex_3d_persistence weighted_alpha_complex_3d_persistence.cpp)
- target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY})
- if (TBB_FOUND)
- target_link_libraries(weighted_alpha_complex_3d_persistence ${TBB_LIBRARIES})
- endif(TBB_FOUND)
-
- install(TARGETS weighted_alpha_complex_3d_persistence DESTINATION bin)
-
- add_test(NAME Persistent_cohomology_example_weighted_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_alpha_complex_3d_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "2" "0.45")
-
endif(CGAL_FOUND)
diff --git a/src/Persistent_cohomology/example/README b/src/Persistent_cohomology/example/README
index 794b94ae..f39d9584 100644
--- a/src/Persistent_cohomology/example/README
+++ b/src/Persistent_cohomology/example/README
@@ -1,43 +1,14 @@
-To build the example, run in a Terminal:
+To build the examples, run in a Terminal:
-cd /path-to-example/
+cd /path-to-examples/
cmake .
make
***********************************************************************************************************************
Example of use of RIPS:
-Computation of the persistent homology with Z/2Z coefficients of the Rips complex on points
-sampling a Klein bottle:
-
-./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2
-
-output:
-2 0 0 inf
-2 1 0.0983494 inf
-2 1 0.104347 inf
-2 2 0.138335 inf
-
-
-Every line is of this format: p1*...*pr dim b d
-where
- p1*...*pr is the product of prime numbers pi such that the homology feature exists in homology with Z/piZ coefficients.
- dim is the dimension of the homological feature,
- b and d are respectively the birth and death of the feature and
-
-
-
-with Z/3Z coefficients:
-
-./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3
-
-output:
-3 0 0 inf
-3 1 0.0983494 inf
-3 1 0.104347 inf
-3 2 0.138335 inf
-
-and the computation with Z/2Z and Z/3Z coefficients simultaneously:
+Computation of the persistent homology with Z/2Z and Z/3Z coefficients simultaneously of the Rips complex
+on points sampling a 3D torus:
./rips_multifield_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.12 -d 3 -p 2 -q 3
@@ -53,7 +24,13 @@ output:
6 0 0 0.12047
6 0 0 0.120414
-and finally the computation with all Z/pZ for 2 <= p <= 71 (20 first prime numbers):
+Every line is of this format: p1*...*pr dim b d
+where
+ p1*...*pr is the product of prime numbers pi such that the homology feature exists in homology with Z/piZ coefficients.
+ dim is the dimension of the homological feature,
+ b and d are respectively the birth and death of the feature and
+
+and the computation with all Z/pZ for 2 <= p <= 71 (20 first prime numbers):
./rips_multifield_persistence ../../data/points/Kl.off -r 0.25 -m 0.5 -d 3 -p 2 -q 71
@@ -70,82 +47,6 @@ output:
557940830126698960967415390 0 0 0.120414
***********************************************************************************************************************
-Example of use of ALPHA:
-
-For a more verbose mode, please run cmake with option "DEBUG_TRACES=TRUE" and recompile the programs.
-
-1) 3D special case
-------------------
-Computation of the persistent homology with Z/2Z coefficients of the alpha complex on points
-sampling a torus 3D:
-
-./alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45
-
-output:
-Simplex_tree dim: 3
-2 0 0 inf
-2 1 0.0682162 1.0001
-2 1 0.0934117 1.00003
-2 2 0.56444 1.03938
-
-Here we retrieve expected Betti numbers on a tore 3D:
-Betti numbers[0] = 1
-Betti numbers[1] = 2
-Betti numbers[2] = 1
-
-N.B.: - alpha_complex_3d_persistence accepts only OFF files in 3D dimension.
- - filtration values are alpha square values
-
-2) d-Dimension case
--------------------
-Computation of the persistent homology with Z/2Z coefficients of the alpha complex on points
-sampling a torus 3D:
-
-./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off
-
-output:
-Alpha complex is of dimension 3 - 9273 simplices - 300 vertices.
-Simplex_tree dim: 3
-2 0 0 inf
-2 1 0.0682162 1.0001
-2 1 0.0934117 1.00003
-2 2 0.56444 1.03938
-
-Here we retrieve expected Betti numbers on a tore 3D:
-Betti numbers[0] = 1
-Betti numbers[1] = 2
-Betti numbers[2] = 1
-
-N.B.: - alpha_complex_persistence accepts OFF files in d-Dimension.
- - filtration values are alpha square values
-
-3) 3D periodic special case
----------------------------
-./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off ../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0
-
-output:
-Periodic Delaunay computed.
-Simplex_tree dim: 3
-3 0 0 inf
-3 1 0.0025 inf
-3 1 0.0025 inf
-3 1 0.0025 inf
-3 2 0.005 inf
-3 2 0.005 inf
-3 2 0.005 inf
-3 3 0.0075 inf
-
-Here we retrieve expected Betti numbers on a tore 3D:
-Betti numbers[0] = 1
-Betti numbers[1] = 3
-Betti numbers[2] = 3
-Betti numbers[3] = 1
-
-N.B.: - periodic_alpha_complex_3d_persistence accepts only OFF files in 3D dimension. In this example, the periodic cube
-is hard coded to { x = [0,1]; y = [0,1]; z = [0,1] }
- - filtration values are alpha square values
-
-***********************************************************************************************************************
Example of use of PLAIN HOMOLOGY:
This example computes the plain homology of the following simplicial complex without filtration values:
diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_helper.h b/src/Persistent_cohomology/example/alpha_complex_3d_helper.h
deleted file mode 100644
index 6b3b7d5d..00000000
--- a/src/Persistent_cohomology/example/alpha_complex_3d_helper.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA Saclay (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef ALPHA_COMPLEX_3D_HELPER_H_
-#define ALPHA_COMPLEX_3D_HELPER_H_
-
-template <class Vertex_list, class Cell_handle>
-Vertex_list from_cell(const Cell_handle& ch) {
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
-#ifdef DEBUG_TRACES
- std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(ch->vertex(i));
- }
- return the_list;
-}
-
-template <class Vertex_list, class Facet>
-Vertex_list from_facet(const Facet& fct) {
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
- if (fct.second != i) {
-#ifdef DEBUG_TRACES
- std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(fct.first->vertex(i));
- }
- }
- return the_list;
-}
-
-template <class Vertex_list, class Edge_3>
-Vertex_list from_edge(const Edge_3& edg) {
- Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
- if ((edg.second == i) || (edg.third == i)) {
-#ifdef DEBUG_TRACES
- std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(edg.first->vertex(i));
- }
- }
- return the_list;
-}
-
-template <class Vertex_list, class Vertex_handle>
-Vertex_list from_vertex(const Vertex_handle& vh) {
- Vertex_list the_list;
-#ifdef DEBUG_TRACES
- std::cout << "from vertex=" << vh->point() << std::endl;
-#endif // DEBUG_TRACES
- the_list.push_back(vh);
- return the_list;
-}
-
-#endif // ALPHA_COMPLEX_3D_HELPER_H_
diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp
deleted file mode 100644
index 26196a6f..00000000
--- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <list>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Alpha_shape_3 templates type definitions
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Kernel>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3>;
-
-// From file type definition
-using Point_3 = Kernel::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName
- << " path_to_the_OFF_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 4) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[2]);
- Filtration_value min_persistence = strtof(argv[3], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the triangulation
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/(*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}
diff --git a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp
deleted file mode 100644
index 9e84e91f..00000000
--- a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <boost/program_options.hpp>
-
-#include <CGAL/Epick_d.h>
-
-#include <gudhi/Alpha_complex.h>
-#include <gudhi/Persistent_cohomology.h>
-// to construct a simplex_tree from alpha complex
-#include <gudhi/Simplex_tree.h>
-
-#include <iostream>
-#include <string>
-#include <limits> // for numeric_limits
-
-using Simplex_tree = Gudhi::Simplex_tree<>;
-using Filtration_value = Simplex_tree::Filtration_value;
-
-void program_options(int argc, char * argv[]
- , std::string & off_file_points
- , std::string & output_file_diag
- , Filtration_value & alpha_square_max_value
- , int & coeff_field_characteristic
- , Filtration_value & min_persistence);
-
-int main(int argc, char **argv) {
- std::string off_file_points;
- std::string output_file_diag;
- Filtration_value alpha_square_max_value;
- int coeff_field_characteristic;
- Filtration_value min_persistence;
-
- program_options(argc, argv, off_file_points, output_file_diag, alpha_square_max_value,
- coeff_field_characteristic, min_persistence);
-
- // ----------------------------------------------------------------------------
- // Init of an alpha complex from an OFF file
- // ----------------------------------------------------------------------------
- using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
- Gudhi::alpha_complex::Alpha_complex<Kernel> alpha_complex_from_file(off_file_points);
-
- Simplex_tree simplex;
- if (alpha_complex_from_file.create_complex(simplex, alpha_square_max_value)) {
- // ----------------------------------------------------------------------------
- // Display information about the alpha complex
- // ----------------------------------------------------------------------------
- std::cout << "Simplicial complex is of dimension " << simplex.dimension() <<
- " - " << simplex.num_simplices() << " simplices - " <<
- simplex.num_vertices() << " vertices." << std::endl;
-
- // Sort the simplices in the order of the filtration
- simplex.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Gudhi::persistent_cohomology::Persistent_cohomology< Simplex_tree,
- Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (output_file_diag.empty()) {
- pcoh.output_diagram();
- } else {
- std::cout << "Result in file: " << output_file_diag << std::endl;
- std::ofstream out(output_file_diag);
- pcoh.output_diagram(out);
- out.close();
- }
- }
-
- return 0;
-}
-
-void program_options(int argc, char * argv[]
- , std::string & off_file_points
- , std::string & output_file_diag
- , Filtration_value & alpha_square_max_value
- , int & coeff_field_characteristic
- , Filtration_value & min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()
- ("input-file", po::value<std::string>(&off_file_points),
- "Name of file containing a point set. Format is one point per line: X1 ... Xd ");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()
- ("help,h", "produce help message")
- ("output-file,o", po::value<std::string>(&output_file_diag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")
- ("max-alpha-square-value,r",
- po::value<Filtration_value>(&alpha_square_max_value)->default_value(std::numeric_limits<Filtration_value>::infinity()),
- "Maximal alpha square value for the Alpha complex construction.")
- ("field-charac,p", po::value<int>(&coeff_field_characteristic)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")
- ("min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).
- options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of an Alpha complex defined on a set of input points.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- std::abort();
- }
-}
diff --git a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index 2e2bfd2f..00000000
--- a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <list>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Alpha_shape_3 templates type definitions
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-using Exact_tag = CGAL::Tag_true;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel, CGAL::Default, Exact_tag>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Kernel, CGAL::Default, Exact_tag>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Delaunay_triangulation_3<Kernel, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3, Exact_tag>;
-
-// From file type definition
-using Point_3 = Kernel::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName
- << " path_to_the_OFF_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 4) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[2]);
- Filtration_value min_persistence = strtof(argv[3], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the triangulation
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- // you can also use the_alpha_value_iterator->exact()
- Filtration_value filtr = /*std::sqrt*/CGAL::to_double(the_alpha_value_iterator->exact());
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}
diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index c6d3e236..00000000
--- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
-#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <list>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Traits
-using K = CGAL::Exact_predicates_inexact_constructions_kernel;
-using PK = CGAL::Periodic_3_Delaunay_triangulation_traits_3<K>;
-// Vertex type
-using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
-using Vb = CGAL::Triangulation_vertex_base_3<PK, DsVb>;
-using AsVb = CGAL::Alpha_shape_vertex_base_3<PK, Vb>;
-// Cell type
-using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
-using Cb = CGAL::Triangulation_cell_base_3<PK, DsCb>;
-using AsCb = CGAL::Alpha_shape_cell_base_3<PK, Cb>;
-using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
-using P3DT3 = CGAL::Periodic_3_Delaunay_triangulation_3<PK, Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<P3DT3>;
-using Point_3 = PK::Point_3;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName << " path_to_the_OFF_file path_to_iso_cuboid_3_file "
- "coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 5) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[3]);
- Filtration_value min_persistence = strtof(argv[4], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Read iso_cuboid_3 information from file
- std::ifstream iso_cuboid_str(argv[2]);
- double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.good()) {
- iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max;
- } else {
- std::cerr << "Unable to read file " << argv[2] << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the triangulation
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Define the periodic cube
- P3DT3 pdt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
- // Heuristic for inserting large point sets (if pts is reasonably large)
- pdt.insert(lp.begin(), lp.end(), true);
- // As pdt won't be modified anymore switch to 1-sheeted cover if possible
- if (pdt.is_triangulation_in_1_sheet()) pdt.convert_to_1_sheeted_covering();
- std::cout << "Periodic Delaunay computed." << std::endl;
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
- // Maybe need to set it to GENERAL mode
- Alpha_shape_3 as(pdt, 0, Alpha_shape_3::GENERAL);
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}
diff --git a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp
deleted file mode 100644
index d38808c7..00000000
--- a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko, Vincent Rouvreau
- *
- * Copyright (C) 2016 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gudhi/Rips_complex.h>
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/reader_utils.h>
-
-#include <boost/program_options.hpp>
-
-#include <string>
-#include <vector>
-#include <limits> // infinity
-
-// Types definition
-using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = Simplex_tree::Filtration_value;
-using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
-using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
-using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp >;
-using Distance_matrix = std::vector<std::vector<Filtration_value>>;
-
-void program_options(int argc, char * argv[]
- , std::string & csv_matrix_file
- , std::string & filediag
- , Filtration_value & threshold
- , int & dim_max
- , int & p
- , Filtration_value & min_persistence);
-
-int main(int argc, char * argv[]) {
- std::string csv_matrix_file;
- std::string filediag;
- Filtration_value threshold;
- int dim_max;
- int p;
- Filtration_value min_persistence;
-
- program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence);
-
- Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file<Filtration_value>(csv_matrix_file);
- Rips_complex rips_complex_from_file(distances, threshold);
-
- // Construct the Rips complex in a Simplex Tree
- Simplex_tree simplex_tree;
-
- rips_complex_from_file.create_complex(simplex_tree, dim_max);
- std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n";
- std::cout << " and has dimension " << simplex_tree.dimension() << " \n";
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(p);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (filediag.empty()) {
- pcoh.output_diagram();
- } else {
- std::ofstream out(filediag);
- pcoh.output_diagram(out);
- out.close();
- }
- return 0;
-}
-
-void program_options(int argc, char * argv[]
- , std::string & csv_matrix_file
- , std::string & filediag
- , Filtration_value & threshold
- , int & dim_max
- , int & p
- , Filtration_value & min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()
- ("input-file", po::value<std::string>(&csv_matrix_file),
- "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'.");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()
- ("help,h", "produce help message")
- ("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")
- ("max-edge-length,r",
- po::value<Filtration_value>(&threshold)->default_value(std::numeric_limits<Filtration_value>::infinity()),
- "Maximal length of an edge for the Rips complex construction.")
- ("cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
- "Maximal dimension of the Rips complex we want to compute.")
- ("field-charac,p", po::value<int>(&p)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")
- ("min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).
- options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a Rips complex defined on a set of distance matrix.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- std::abort();
- }
-}
diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp
deleted file mode 100644
index d504798b..00000000
--- a/src/Persistent_cohomology/example/rips_persistence.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gudhi/Rips_complex.h>
-#include <gudhi/distance_functions.h>
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_off_io.h>
-
-#include <boost/program_options.hpp>
-
-#include <string>
-#include <vector>
-#include <limits> // infinity
-
-// Types definition
-using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = Simplex_tree::Filtration_value;
-using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
-using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
-using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp >;
-using Point = std::vector<double>;
-using Points_off_reader = Gudhi::Points_off_reader<Point>;
-
-void program_options(int argc, char * argv[]
- , std::string & off_file_points
- , std::string & filediag
- , Filtration_value & threshold
- , int & dim_max
- , int & p
- , Filtration_value & min_persistence);
-
-int main(int argc, char * argv[]) {
- std::string off_file_points;
- std::string filediag;
- Filtration_value threshold;
- int dim_max;
- int p;
- Filtration_value min_persistence;
-
- program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence);
-
- Points_off_reader off_reader(off_file_points);
- Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Gudhi::Euclidean_distance());
-
- // Construct the Rips complex in a Simplex Tree
- Simplex_tree simplex_tree;
-
- rips_complex_from_file.create_complex(simplex_tree, dim_max);
- std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n";
- std::cout << " and has dimension " << simplex_tree.dimension() << " \n";
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(p);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- // Output the diagram in filediag
- if (filediag.empty()) {
- pcoh.output_diagram();
- } else {
- std::ofstream out(filediag);
- pcoh.output_diagram(out);
- out.close();
- }
-
- return 0;
-}
-
-void program_options(int argc, char * argv[]
- , std::string & off_file_points
- , std::string & filediag
- , Filtration_value & threshold
- , int & dim_max
- , int & p
- , Filtration_value & min_persistence) {
- namespace po = boost::program_options;
- po::options_description hidden("Hidden options");
- hidden.add_options()
- ("input-file", po::value<std::string>(&off_file_points),
- "Name of an OFF file containing a point set.\n");
-
- po::options_description visible("Allowed options", 100);
- visible.add_options()
- ("help,h", "produce help message")
- ("output-file,o", po::value<std::string>(&filediag)->default_value(std::string()),
- "Name of file in which the persistence diagram is written. Default print in std::cout")
- ("max-edge-length,r",
- po::value<Filtration_value>(&threshold)->default_value(std::numeric_limits<Filtration_value>::infinity()),
- "Maximal length of an edge for the Rips complex construction.")
- ("cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
- "Maximal dimension of the Rips complex we want to compute.")
- ("field-charac,p", po::value<int>(&p)->default_value(11),
- "Characteristic p of the coefficient field Z/pZ for computing homology.")
- ("min-persistence,m", po::value<Filtration_value>(&min_persistence),
- "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals");
-
- po::positional_options_description pos;
- pos.add("input-file", 1);
-
- po::options_description all;
- all.add(visible).add(hidden);
-
- po::variables_map vm;
- po::store(po::command_line_parser(argc, argv).
- options(all).positional(pos).run(), vm);
- po::notify(vm);
-
- if (vm.count("help") || !vm.count("input-file")) {
- std::cout << std::endl;
- std::cout << "Compute the persistent homology with coefficient field Z/pZ \n";
- std::cout << "of a Rips complex defined on a set of input points.\n \n";
- std::cout << "The output diagram contains one bar per line, written with the convention: \n";
- std::cout << " p dim b d \n";
- std::cout << "where dim is the dimension of the homological feature,\n";
- std::cout << "b and d are respectively the birth and death of the feature and \n";
- std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl;
-
- std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl;
- std::cout << visible << std::endl;
- std::abort();
- }
-}
diff --git a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp
index 554eeba6..c1de0ef8 100644
--- a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp
+++ b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp
@@ -45,14 +45,7 @@
using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Vertex_handle = Simplex_tree::Vertex_handle;
using Filtration_value = Simplex_tree::Filtration_value;
-using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS
-, boost::property < vertex_filtration_t, Filtration_value >
-, boost::property < edge_filtration_t, Filtration_value >
->;
-using Edge_t = std::pair< Vertex_handle, Vertex_handle >;
-
-template< typename InputPointRange, typename Distance >
-Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold, Distance distance);
+using Proximity_graph = Gudhi::Proximity_graph<Simplex_tree>;
using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp >;
@@ -81,8 +74,9 @@ int main(int argc, char * argv[]) {
Points_off_reader off_reader(off_file_points);
// Compute the proximity graph of the points
- Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold
- , Gudhi::Euclidean_distance());
+ Proximity_graph prox_graph = Gudhi::compute_proximity_graph<Simplex_tree>(off_reader.get_point_cloud(),
+ threshold,
+ Gudhi::Euclidean_distance());
// Construct the Rips complex in a Simplex Tree
Simplex_tree st;
@@ -170,48 +164,3 @@ void program_options(int argc, char * argv[]
std::abort();
}
}
-
-/** Output the proximity graph of the points.
- *
- * If points contains n elements, the proximity graph is the graph
- * with n vertices, and an edge [u,v] iff the distance function between
- * points u and v is smaller than threshold.
- *
- * The type PointCloud furnishes .begin() and .end() methods, that return
- * iterators with value_type Point.
- */
-template< typename InputPointRange, typename Distance >
-Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold, Distance distance) {
- std::vector< Edge_t > edges;
- std::vector< Filtration_value > edges_fil;
-
- Vertex_handle idx_u, idx_v;
- Filtration_value fil;
- idx_u = 0;
- for (auto it_u = points.begin(); it_u != points.end(); ++it_u) {
- idx_v = idx_u + 1;
- for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) {
- fil = distance(*it_u, *it_v);
- if (fil <= threshold) {
- edges.emplace_back(idx_u, idx_v);
- edges_fil.push_back(fil);
- }
- }
- ++idx_u;
- }
-
- Graph_t skel_graph(edges.begin()
- , edges.end()
- , edges_fil.begin()
- , idx_u); // number of points labeled from 0 to idx_u-1
-
- auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph);
-
- boost::graph_traits<Graph_t>::vertex_iterator vi, vi_end;
- for (std::tie(vi, vi_end) = boost::vertices(skel_graph);
- vi != vi_end; ++vi) {
- boost::put(vertex_prop, *vi, 0.);
- }
-
- return skel_graph;
-}
diff --git a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index 249a7ece..00000000
--- a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/config.h>
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Regular_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/iterator.h>
-
-// For CGAL < 4.11
-#if CGAL_VERSION_NR < 1041100000
-#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
-#endif // CGAL_VERSION_NR < 1041100000
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <list>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Alpha_shape_3 templates type definitions
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-
-// For CGAL < 4.11
-#if CGAL_VERSION_NR < 1041100000
-using Gt = CGAL::Regular_triangulation_euclidean_traits_3<Kernel>;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Gt>;
-using Fb = CGAL::Alpha_shape_cell_base_3<Gt>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb, Fb>;
-using Triangulation_3 = CGAL::Regular_triangulation_3<Gt, Tds>;
-
-// From file type definition
-using Point_3 = Gt::Bare_point;
-using Weighted_point_3 = Gt::Weighted_point;
-
-// For CGAL >= 4.11
-#else // CGAL_VERSION_NR < 1041100000
-using Rvb = CGAL::Regular_triangulation_vertex_base_3<Kernel>;
-using Vb = CGAL::Alpha_shape_vertex_base_3<Kernel,Rvb>;
-using Rcb = CGAL::Regular_triangulation_cell_base_3<Kernel>;
-using Cb = CGAL::Alpha_shape_cell_base_3<Kernel,Rcb>;
-using Tds = CGAL::Triangulation_data_structure_3<Vb,Cb>;
-using Triangulation_3 = CGAL::Regular_triangulation_3<Kernel,Tds>;
-
-// From file type definition
-using Point_3 = Triangulation_3::Bare_point;
-using Weighted_point_3 = Triangulation_3::Weighted_point;
-#endif // CGAL_VERSION_NR < 1041100000
-
-using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3>;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName << " path_to_the_OFF_file path_to_weight_file coeff_field_characteristic[integer > "
- "0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 5) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[3]);
- Filtration_value min_persistence = strtof(argv[4], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the triangulation
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Read weights information from file
- std::ifstream weights_ifstr(argv[2]);
- std::vector<Weighted_point_3> wp;
- if (weights_ifstr.good()) {
- double weight = 0.0;
- std::size_t index = 0;
- wp.reserve(lp.size());
- // Attempt read the weight in a double format, return false if it fails
- while ((weights_ifstr >> weight) && (index < lp.size())) {
- wp.push_back(Weighted_point_3(lp[index], weight));
- index++;
- }
- if (index != lp.size()) {
- std::cerr << "Bad number of weights in file " << argv[2] << std::endl;
- usage(argv[0]);
- }
- } else {
- std::cerr << "Unable to read file " << argv[2] << std::endl;
- usage(argv[0]);
- }
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(wp.begin(), wp.end(), 0, Alpha_shape_3::GENERAL);
-#ifdef DEBUG_TRACES
- std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
-#endif // DEBUG_TRACES
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}
diff --git a/src/Persistent_cohomology/example/weighted_periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_periodic_alpha_complex_3d_persistence.cpp
deleted file mode 100644
index 13634ff7..00000000
--- a/src/Persistent_cohomology/example/weighted_periodic_alpha_complex_3d_persistence.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2014 INRIA
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <boost/variant.hpp>
-
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-#include <gudhi/Points_3D_off_io.h>
-
-#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-#include <CGAL/Periodic_3_regular_triangulation_traits_3.h>
-#include <CGAL/Periodic_3_regular_triangulation_3.h>
-#include <CGAL/Alpha_shape_3.h>
-#include <CGAL/iterator.h>
-
-#include <fstream>
-#include <cmath>
-#include <string>
-#include <tuple>
-#include <map>
-#include <utility>
-#include <list>
-#include <vector>
-#include <cstdlib>
-
-#include "alpha_complex_3d_helper.h"
-
-// Traits
-using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
-using PK = CGAL::Periodic_3_regular_triangulation_traits_3<Kernel>;
-
-// Vertex type
-using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
-using Vb = CGAL::Regular_triangulation_vertex_base_3<PK,DsVb>;
-using AsVb = CGAL::Alpha_shape_vertex_base_3<PK,Vb>;
-// Cell type
-using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
-using Cb = CGAL::Regular_triangulation_cell_base_3<PK,DsCb>;
-using AsCb = CGAL::Alpha_shape_cell_base_3<PK,Cb>;
-using Tds = CGAL::Triangulation_data_structure_3<AsVb,AsCb>;
-using P3RT3 = CGAL::Periodic_3_regular_triangulation_3<PK,Tds>;
-using Alpha_shape_3 = CGAL::Alpha_shape_3<P3RT3>;
-
-using Point_3 = P3RT3::Bare_point;
-using Weighted_point_3 = P3RT3::Weighted_point;
-
-// filtration with alpha values needed type definition
-using Alpha_value_type = Alpha_shape_3::FT;
-using Object = CGAL::Object;
-using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
-using Cell_handle = Alpha_shape_3::Cell_handle;
-using Facet = Alpha_shape_3::Facet;
-using Edge_3 = Alpha_shape_3::Edge;
-using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
-
-// gudhi type definition
-using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = ST::Filtration_value;
-using Simplex_tree_vertex = ST::Vertex_handle;
-using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
-using Persistent_cohomology =
- Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
-
-void usage(const std::string& progName) {
- std::cerr << "Usage: " << progName << " path_to_the_OFF_file path_to_weight_file path_to_the_cuboid_file "
- "coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
- exit(-1);
-}
-
-int main(int argc, char* const argv[]) {
- // program args management
- if (argc != 6) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
- usage(argv[0]);
- }
-
- int coeff_field_characteristic = atoi(argv[4]);
- Filtration_value min_persistence = strtof(argv[5], nullptr);
-
- // Read points from file
- std::string offInputFile(argv[1]);
- // Read the OFF file (input file name given as parameter) and triangulate points
- Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- usage(argv[0]);
- }
-
- // Retrieve the triangulation
- std::vector<Point_3> lp = off_reader.get_point_cloud();
-
- // Read weights information from file
- std::ifstream weights_ifstr(argv[2]);
- std::vector<Weighted_point_3> wp;
- if (weights_ifstr.good()) {
- double weight = 0.0;
- std::size_t index = 0;
- wp.reserve(lp.size());
- // Attempt read the weight in a double format, return false if it fails
- while ((weights_ifstr >> weight) && (index < lp.size())) {
- wp.push_back(Weighted_point_3(lp[index], weight));
- index++;
- }
- if (index != lp.size()) {
- std::cerr << "Bad number of weights in file " << argv[2] << std::endl;
- usage(argv[0]);
- }
- } else {
- std::cerr << "Unable to read file " << argv[2] << std::endl;
- usage(argv[0]);
- }
-
- // Read iso_cuboid_3 information from file
- std::ifstream iso_cuboid_str(argv[3]);
- double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.good()) {
- iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max;
- } else {
- std::cerr << "Unable to read file " << argv[3] << std::endl;
- usage(argv[0]);
- }
-
- // Define the periodic cube
- P3RT3 prt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
- // Heuristic for inserting large point sets (if pts is reasonably large)
- prt.insert(wp.begin(), wp.end(), true);
- // As prt won't be modified anymore switch to 1-sheeted cover if possible
- if (prt.is_triangulation_in_1_sheet()) prt.convert_to_1_sheeted_covering();
- std::cout << "Periodic Delaunay computed." << std::endl;
-
- // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
- // Maybe need to set it to GENERAL mode
- Alpha_shape_3 as(prt, 0, Alpha_shape_3::GENERAL);
-
- // filtration with alpha values from alpha shape
- std::vector<Object> the_objects;
- std::vector<Alpha_value_type> the_alpha_values;
-
- Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
- std::back_inserter(the_alpha_values));
-
- as.filtration_with_alpha_values(disp);
-#ifdef DEBUG_TRACES
- std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
-#endif // DEBUG_TRACES
-
- Alpha_shape_3::size_type count_vertices = 0;
- Alpha_shape_3::size_type count_edges = 0;
- Alpha_shape_3::size_type count_facets = 0;
- Alpha_shape_3::size_type count_cells = 0;
-
- // Loop on objects vector
- Vertex_list vertex_list;
- ST simplex_tree;
- Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
- std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
- for (auto object_iterator : the_objects) {
- // Retrieve Alpha shape vertex list from object
- if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
- vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
- count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
- } else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
- vertex_list = from_facet<Vertex_list, Facet>(*facet);
- count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
- } else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
- vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
- count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
- } else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
- count_vertices++;
- vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
- }
- // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
- for (auto the_alpha_shape_vertex : vertex_list) {
- Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
- if (the_map_iterator == map_cgal_simplex_tree.end()) {
- // alpha shape not found
- Simplex_tree_vertex vertex = map_cgal_simplex_tree.size();
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
- } else {
- // alpha shape found
- Simplex_tree_vertex vertex = the_map_iterator->second;
-#ifdef DEBUG_TRACES
- std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
-#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- }
- }
- // Construction of the simplex_tree
- Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator);
-#ifdef DEBUG_TRACES
- std::cout << "filtration = " << filtr << std::endl;
-#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
- }
-
-#ifdef DEBUG_TRACES
- std::cout << "vertices \t\t" << count_vertices << std::endl;
- std::cout << "edges \t\t" << count_edges << std::endl;
- std::cout << "facets \t\t" << count_facets << std::endl;
- std::cout << "cells \t\t" << count_cells << std::endl;
-
- std::cout << "Information of the Simplex Tree: " << std::endl;
- std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
- std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
- std::cout << " Dimension = " << simplex_tree.dimension() << " ";
-#endif // DEBUG_TRACES
-
-#ifdef DEBUG_TRACES
- std::cout << "Iterator on vertices: " << std::endl;
- for (auto vertex : simplex_tree.complex_vertex_range()) {
- std::cout << vertex << " ";
- }
-#endif // DEBUG_TRACES
-
- // Sort the simplices in the order of the filtration
- simplex_tree.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Persistent_cohomology pcoh(simplex_tree, true);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence);
-
- pcoh.output_diagram();
-
- return 0;
-}