diff options
Diffstat (limited to 'src/Persistent_cohomology/example/plain_homology.cpp')
-rw-r--r-- | src/Persistent_cohomology/example/plain_homology.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index 0a692717..ae82c817 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -24,6 +24,8 @@ #include <gudhi/Persistent_cohomology.h> #include <iostream> +#include <vector> +#include <cstdint> // for std::uint8_t using namespace Gudhi; @@ -38,6 +40,8 @@ struct MyOptions : Simplex_tree_options_full_featured { static const bool store_key = true; // I have few vertices typedef short Vertex_handle; + // Maximum number of simplices to compute persistence is 2^8 - 1 = 255. One is reserved for null_key + typedef std::uint8_t Simplex_key; }; typedef Simplex_tree<MyOptions> ST; @@ -76,9 +80,16 @@ int main() { // Print the result. The format is, on each line: 2 dim 0 inf // where 2 represents the field, dim the dimension of the feature. - // 2 0 0 inf - // 2 0 0 inf - // 2 1 0 inf + // 2 0 0 inf + // 2 0 0 inf + // 2 1 0 inf // means that in Z/2Z-homology, the Betti numbers are b0=2 and b1=1. pcoh.output_diagram(); + + // Print the Betti numbers are b0=2 and b1=1. + std::cout << std::endl; + std::cout << "The Betti numbers are : "; + for (int i = 0; i < st.dimension(); i++) + std::cout << "b" << i << " = " << pcoh.betti_number(i) << " ; "; + std::cout << std::endl; } |