diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-04-04 06:11:17 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-04-04 06:11:17 +0000 |
commit | 94c3a7705bf95983e76ff136108bf9846869868b (patch) | |
tree | addc5f9ae4d2fdf23c0ff2f0f161947e369f92c9 /src/Rips_complex/example | |
parent | c06596e61c92f54a01756e1ba1babaff800f0f02 (diff) | |
parent | 1e55ed3f7ce467f598c66e18e6a7337476961588 (diff) |
Merge sparse rips branch in trunk
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3336 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 01dcab006197637ccba9c29f8990375fe05ad7b4
Diffstat (limited to 'src/Rips_complex/example')
-rw-r--r-- | src/Rips_complex/example/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Rips_complex/example/example_sparse_rips.cpp | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index fcb1eaee..af86636b 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -11,6 +11,9 @@ add_executable ( Rips_complex_example_one_skeleton_from_distance_matrix example_ add_executable ( Rips_complex_example_from_csv_distance_matrix example_rips_complex_from_csv_distance_matrix_file.cpp ) +# Sparse rips from points +add_executable ( Rips_complex_example_sparse example_sparse_rips.cpp ) + # Correlation matrix add_executable ( Rips_complex_example_one_skeleton_rips_from_correlation_matrix example_one_skeleton_rips_from_correlation_matrix.cpp ) @@ -19,6 +22,7 @@ if (TBB_FOUND) target_link_libraries(Rips_complex_example_one_skeleton_from_points ${TBB_LIBRARIES}) target_link_libraries(Rips_complex_example_one_skeleton_from_distance_matrix ${TBB_LIBRARIES}) target_link_libraries(Rips_complex_example_from_csv_distance_matrix ${TBB_LIBRARIES}) + target_link_libraries(Rips_complex_example_sparse ${TBB_LIBRARIES}) target_link_libraries(Rips_complex_example_one_skeleton_rips_from_correlation_matrix ${TBB_LIBRARIES}) endif() @@ -26,6 +30,8 @@ add_test(NAME Rips_complex_example_one_skeleton_from_points COMMAND $<TARGET_FILE:Rips_complex_example_one_skeleton_from_points>) add_test(NAME Rips_complex_example_one_skeleton_from_distance_matrix COMMAND $<TARGET_FILE:Rips_complex_example_one_skeleton_from_distance_matrix>) +add_test(NAME Rips_complex_example_sparse + COMMAND $<TARGET_FILE:Rips_complex_example_sparse>) add_test(NAME Rips_complex_example_one_skeleton_rips_from_correlation_matrix COMMAND $<TARGET_FILE:Rips_complex_example_one_skeleton_rips_from_correlation_matrix>) diff --git a/src/Rips_complex/example/example_sparse_rips.cpp b/src/Rips_complex/example/example_sparse_rips.cpp new file mode 100644 index 00000000..1c95b48c --- /dev/null +++ b/src/Rips_complex/example/example_sparse_rips.cpp @@ -0,0 +1,30 @@ +#include <gudhi/Sparse_rips_complex.h> +#include <gudhi/Simplex_tree.h> +#include <gudhi/distance_functions.h> + +#include <iostream> +#include <vector> + +int main() { + using Point = std::vector<double>; + using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; + using Filtration_value = Simplex_tree::Filtration_value; + using Sparse_rips = Gudhi::rips_complex::Sparse_rips_complex<Filtration_value>; + + Point points[] = {{1.0, 1.0}, {7.0, 0.0}, {4.0, 6.0}, {9.0, 6.0}, {0.0, 14.0}, {2.0, 19.0}, {9.0, 17.0}}; + + // ---------------------------------------------------------------------------- + // Init from Euclidean points + // ---------------------------------------------------------------------------- + double epsilon = 2; // very rough, no guarantees + Sparse_rips sparse_rips(points, Gudhi::Euclidean_distance(), epsilon); + + Simplex_tree stree; + sparse_rips.create_complex(stree, 10); + + // ---------------------------------------------------------------------------- + // Display information about the complex + // ---------------------------------------------------------------------------- + std::cout << "Sparse Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() + << " simplices - " << stree.num_vertices() << " vertices." << std::endl; +} |