11 #ifndef RIPS_COMPLEX_H_
12 #define RIPS_COMPLEX_H_
14 #include <gudhi/Debug_utils.h>
17 #include <boost/graph/adjacency_list.hpp>
29 namespace rips_complex {
44 template<
typename Filtration_value>
50 typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS
51 , boost::property < vertex_filtration_t, Filtration_value >
55 typedef int Vertex_handle;
72 template<
typename ForwardPo
intRange,
typename Distance >
74 compute_proximity_graph(points, threshold, distance);
87 template<
typename DistanceMatrix>
89 compute_proximity_graph(boost::irange((
size_t)0, distance_matrix.size()), threshold,
90 [&](
size_t i,
size_t j){return distance_matrix[j][i];});
103 template <
typename SimplicialComplexForRips>
106 std::invalid_argument(
"Rips_complex::create_complex - simplicial complex is not empty"));
126 template<
typename ForwardPo
intRange,
typename Distance >
127 void compute_proximity_graph(
const ForwardPointRange& points,
Filtration_value threshold,
129 std::vector< std::pair< Vertex_handle, Vertex_handle > > edges;
130 std::vector< Filtration_value > edges_fil;
138 for (
auto it_u = std::begin(points); it_u != std::end(points); ++it_u, ++idx_u) {
140 for (
auto it_v = it_u + 1; it_v != std::end(points); ++it_v, ++idx_v) {
142 if (fil <= threshold) {
143 edges.emplace_back(idx_u, idx_v);
144 edges_fil.push_back(fil);
155 rips_skeleton_graph_.~OneSkeletonGraph();
156 new(&rips_skeleton_graph_)
OneSkeletonGraph(edges.begin(), edges.end(), edges_fil.begin(), idx_u);
158 auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_);
160 using vertex_iterator =
typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator;
161 vertex_iterator vi, vi_end;
162 for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_);
163 vi != vi_end; ++vi) {
164 boost::put(vertex_prop, *vi, 0.);
Rips complex data structure.
Definition: Rips_complex.h:45
Rips_complex(const ForwardPointRange &points, Filtration_value threshold, Distance distance)
Rips_complex constructor from a list of points.
Definition: Rips_complex.h:73
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::property< vertex_filtration_t, Filtration_value >, boost::property< edge_filtration_t, Filtration_value > > OneSkeletonGraph
Type of the one skeleton graph stored inside the Rips complex structure.
Definition: Rips_complex.h:52
void create_complex(SimplicialComplexForRips &complex, int dim_max)
Initializes the simplicial complex from the Rips graph and expands it until a given maximal dimension...
Definition: Rips_complex.h:104
Rips_complex(const DistanceMatrix &distance_matrix, Filtration_value threshold)
Rips_complex constructor from a distance matrix.
Definition: Rips_complex.h:88
Graph simplicial complex methods.
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Value type for a filtration function on a cell complex.
Definition: FiltrationValue.h:20
The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial ...
Definition: SimplicialComplexForRips.h:21
std::size_t num_vertices()
Returns the number of vertices in the simplicial complex.
void expansion(int max_dim)
Expands the simplicial complex containing only its one skeleton until a given maximal dimension as ex...
void insert_graph(const OneSkeletonGraph &skel_graph)
Inserts a given Gudhi::rips_complex::Rips_complex::OneSkeletonGraph in the simplicial complex.
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15