From e0ba917bbb1a54d43642f14eccb0bb6af8792bc2 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 13 Jun 2019 11:27:21 +0200 Subject: Modify plain_homology example to highlight persistence_dim_max parameter --- .../example/plain_homology.cpp | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index a2256060..be2dc4cc 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -50,26 +50,33 @@ int main() { ST st; /* Complex to build. */ - /* 1 3 */ - /* o---o */ - /* /X\ / */ + /* 1 3 5 */ + /* o---o---o */ + /* / \ / */ /* o---o o */ /* 2 0 4 */ - const short triangle012[] = {0, 1, 2}; + const short edge01[] = {0, 1}; + const short edge02[] = {0, 2}; + const short edge12[] = {1, 2}; const short edge03[] = {0, 3}; const short edge13[] = {1, 3}; + const short edge35[] = {3, 5}; const short vertex4[] = {4}; - st.insert_simplex_and_subfaces(triangle012); + st.insert_simplex_and_subfaces(edge01); + st.insert_simplex_and_subfaces(edge02); + st.insert_simplex_and_subfaces(edge12); st.insert_simplex_and_subfaces(edge03); st.insert_simplex(edge13); + st.insert_simplex_and_subfaces(edge35); st.insert_simplex(vertex4); // Sort the simplices in the order of the filtration st.initialize_filtration(); // Class for homology computation - Persistent_cohomology pcoh(st); + // We want persistent homology to be computed for the maximal dimension in the complex (persistence_dim_max = true) + Persistent_cohomology pcoh(st, true); // Initialize the coefficient field Z/2Z for homology pcoh.init_coefficients(2); @@ -82,13 +89,14 @@ int main() { // 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. + // 2 1 0 inf + // means that in Z/2Z-homology, the Betti numbers are b0=2 and b1=2. pcoh.output_diagram(); - // Print the Betti numbers are b0=2 and b1=1. + // Print the Betti numbers are b0=2 and b1=2. std::cout << std::endl; std::cout << "The Betti numbers are : "; - for (int i = 0; i < st.dimension(); i++) + for (int i = 0; i < 3; i++) std::cout << "b" << i << " = " << pcoh.betti_number(i) << " ; "; std::cout << std::endl; } -- cgit v1.2.3