cech_complex_example_from_points.cpp

Bitmap_cubical_complex

#include <gudhi/Cech_complex.h>
#include <gudhi/Simplex_tree.h>
#include <iostream>
#include <string>
#include <vector>
#include <array>
int main() {
// Type definitions
using Point_cloud = std::vector<std::array<double, 2>>;
Point_cloud points;
points.push_back({1., 0.}); // 0
points.push_back({0., 1.}); // 1
points.push_back({2., 1.}); // 2
points.push_back({3., 2.}); // 3
points.push_back({0., 3.}); // 4
points.push_back({3. + std::sqrt(3.), 3.}); // 5
points.push_back({1., 4.}); // 6
points.push_back({3., 4.}); // 7
points.push_back({2., 4. + std::sqrt(3.)}); // 8
points.push_back({0., 4.}); // 9
points.push_back({-0.5, 2.}); // 10
// ----------------------------------------------------------------------------
// Init of a Cech complex from points
// ----------------------------------------------------------------------------
Filtration_value max_radius = 1.;
Cech_complex cech_complex_from_points(points, max_radius);
Simplex_tree stree;
cech_complex_from_points.create_complex(stree, 2);
// ----------------------------------------------------------------------------
// Display information about the one skeleton Cech complex
// ----------------------------------------------------------------------------
std::clog << "Cech complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - "
<< stree.num_vertices() << " vertices." << std::endl;
std::clog << "Iterator on Cech complex simplices in the filtration order, with [filtration value]:" << std::endl;
for (auto f_simplex : stree.filtration_simplex_range()) {
std::clog << " ( ";
for (auto vertex : stree.simplex_vertex_range(f_simplex)) {
std::clog << vertex << " ";
}
std::clog << ") -> "
<< "[" << stree.filtration(f_simplex) << "] ";
std::clog << std::endl;
}
return 0;
}
Options::Filtration_value Filtration_value
Type for the value of the filtration function.
Definition: Simplex_tree.h:82
Filtration_simplex_range const & filtration_simplex_range(Indexing_tag=Indexing_tag())
Returns a range over the simplices of the simplicial complex, in the order of the filtration.
Definition: Simplex_tree.h:262
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh) const
Returns a range over the vertices of a simplex.
Definition: Simplex_tree.h:273
static Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition: Simplex_tree.h:509
size_t num_vertices() const
Returns the number of vertices in the complex.
Definition: Simplex_tree.h:546
int dimension(Simplex_handle sh)
Returns the dimension of a simplex.
Definition: Simplex_tree.h:574
size_t num_simplices()
returns the number of simplices in the simplex_tree.
Definition: Simplex_tree.h:552
Cech complex data structure.
Definition: Cech_complex.h:44
void create_complex(SimplicialComplexForCechComplex &complex, int dim_max)
Initializes the simplicial complex from the proximity graph and expands it until a given maximal dime...
Definition: Cech_complex.h:89
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20
GUDHI  Version 3.5.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Thu Jan 13 2022 08:34:27 for GUDHI by Doxygen 1.9.2