Loading...
Searching...
No Matches
Cech_complex.h
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau, Hind Montassif
*
* Copyright (C) 2018 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
* - 2022/02 Hind Montassif : Replace MiniBall with Sphere_circumradius
*/
#ifndef CECH_COMPLEX_H_
#define CECH_COMPLEX_H_
#include <gudhi/Sphere_circumradius.h> // for Gudhi::cech_complex::Sphere_circumradius
#include <gudhi/graph_simplicial_complex.h> // for Gudhi::Proximity_graph
#include <gudhi/Debug_utils.h> // for GUDHI_CHECK
#include <gudhi/Cech_complex_blocker.h> // for Gudhi::cech_complex::Cech_blocker
#include <iostream>
#include <stdexcept> // for exception management
namespace Gudhi {
namespace cech_complex {
template <typename Kernel, typename SimplicialComplexForCechComplex>
class Cech_complex {
private:
// Required by compute_proximity_graph
using Vertex_handle = typename SimplicialComplexForCechComplex::Vertex_handle;
using Filtration_value = typename SimplicialComplexForCechComplex::Filtration_value;
using Proximity_graph = Gudhi::Proximity_graph<SimplicialComplexForCechComplex>;
using cech_blocker = Cech_blocker<SimplicialComplexForCechComplex, Cech_complex, Kernel>;
using Point_d = typename cech_blocker::Point_d;
using Point_cloud = std::vector<Point_d>;
// Numeric type of coordinates in the kernel
using FT = typename cech_blocker::FT;
// Sphere is a pair of point and squared radius.
using Sphere = typename cech_blocker::Sphere;
public:
template<typename InputPointRange >
Cech_complex(const InputPointRange & points, Filtration_value max_radius, const bool exact = false) : max_radius_(max_radius), exact_(exact) {
point_cloud_.assign(std::begin(points), std::end(points));
cech_skeleton_graph_ = Gudhi::compute_proximity_graph<SimplicialComplexForCechComplex>(
point_cloud_, max_radius_, Sphere_circumradius<Kernel, Filtration_value>(exact));
}
void create_complex(SimplicialComplexForCechComplex& complex, int dim_max) {
GUDHI_CHECK(complex.num_vertices() == 0,
std::invalid_argument("Cech_complex::create_complex - simplicial complex is not empty"));
// insert the proximity graph in the simplicial complex
complex.insert_graph(cech_skeleton_graph_);
// expand the graph until dimension dim_max
complex.expansion_with_blockers(dim_max, cech_blocker(&complex, this));
}
Filtration_value max_radius() const { return max_radius_; }
const Point_d& get_point(Vertex_handle vertex) const { return point_cloud_[vertex]; }
std::vector<Sphere> & get_cache() { return cache_; }
const bool is_exact() { return exact_; }
private:
Proximity_graph cech_skeleton_graph_;
Filtration_value max_radius_;
Point_cloud point_cloud_;
std::vector<Sphere> cache_;
const bool exact_;
};
} // namespace cech_complex
} // namespace Gudhi
#endif // CECH_COMPLEX_H_
Gudhi::cech_complex::Cech_complex::Cech_complex
Cech_complex(const InputPointRange &points, Filtration_value max_radius, const bool exact=false)
Cech_complex constructor from a range of points.
Definition Cech_complex.h:72
Gudhi::cech_complex::Cech_complex::get_point
const Point_d & get_point(Vertex_handle vertex) const
Definition Cech_complex.h:104
Gudhi::cech_complex::Cech_complex::get_cache
std::vector< Sphere > & get_cache()
Definition Cech_complex.h:109
Gudhi::cech_complex::Cech_complex::is_exact
const bool is_exact()
Check exact option.
Definition Cech_complex.h:114
Gudhi::cech_complex::Cech_complex::create_complex
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:88
Gudhi::cech_complex::Cech_complex::max_radius
Filtration_value max_radius() const
Definition Cech_complex.h:99
graph_simplicial_complex.h
Graph simplicial complex methods.
Gudhi
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14
Gudhi::Proximity_graph
typename boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >, boost::property< edge_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > > Proximity_graph
Proximity_graph contains the vertices and edges with their filtration values in order to store the re...
Definition graph_simplicial_complex.h:43
Gudhi::compute_proximity_graph
Proximity_graph< SimplicialComplexForProximityGraph > compute_proximity_graph(const ForwardPointRange &points, typename SimplicialComplexForProximityGraph::Filtration_value threshold, Distance distance)
Computes the proximity graph of the points.
Definition graph_simplicial_complex.h:62