11 #ifndef RIPS_COMPLEX_H_
12 #define RIPS_COMPLEX_H_
14 #include <gudhi/Debug_utils.h>
15 #include <gudhi/graph_simplicial_complex.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;
70 template<
typename ForwardPo
intRange,
typename Distance >
72 compute_proximity_graph(points, threshold, distance);
84 template<
typename DistanceMatrix>
86 compute_proximity_graph(boost::irange((
size_t)0, distance_matrix.size()), threshold,
87 [&](
size_t i,
size_t j){
return distance_matrix[j][i];});
100 template <
typename SimplicialComplexForRips>
103 std::invalid_argument(
"Rips_complex::create_complex - simplicial complex is not empty"));
123 template<
typename ForwardPo
intRange,
typename Distance >
124 void compute_proximity_graph(
const ForwardPointRange& points,
Filtration_value threshold,
126 std::vector< std::pair< Vertex_handle, Vertex_handle > > edges;
127 std::vector< Filtration_value > edges_fil;
134 Vertex_handle idx_u = 0;
135 for (
auto it_u = std::begin(points); it_u != std::end(points); ++it_u, ++idx_u) {
136 Vertex_handle idx_v = idx_u + 1;
137 for (
auto it_v = it_u + 1; it_v != std::end(points); ++it_v, ++idx_v) {
139 if (fil <= threshold) {
140 edges.emplace_back(idx_u, idx_v);
141 edges_fil.push_back(fil);
152 rips_skeleton_graph_.~OneSkeletonGraph();
153 new(&rips_skeleton_graph_)
OneSkeletonGraph(edges.begin(), edges.end(), edges_fil.begin(), idx_u);
155 auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_);
157 using vertex_iterator =
typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator;
158 vertex_iterator vi, vi_end;
159 for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_);
160 vi != vi_end; ++vi) {
161 boost::put(vertex_prop, *vi, 0.);
173 #endif // RIPS_COMPLEX_H_