23 #ifndef GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H
24 #define GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H
26 #include <boost/graph/adjacency_list.hpp>
29 struct edge_filtration_t {
30 typedef boost::edge_property_tag kind;
33 struct vertex_filtration_t {
34 typedef boost::vertex_property_tag kind;
37 typedef int Vertex_handle;
38 typedef double Filtration_value;
39 typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS
40 , boost::property < vertex_filtration_t, Filtration_value >
41 , boost::property < edge_filtration_t, Filtration_value >
43 typedef std::pair< Vertex_handle, Vertex_handle > Edge_t;
54 template<
typename PointCloud
56 Graph_t compute_proximity_graph( PointCloud &points
57 , Filtration_value threshold
58 , Filtration_value distance(Point p1, Point p2) )
60 std::vector< Edge_t > edges;
61 std::vector< Filtration_value > edges_fil;
62 std::map< Vertex_handle, Filtration_value > vertices;
64 Vertex_handle idx_u, idx_v;
67 for(
auto it_u = points.begin(); it_u != points.end(); ++it_u)
70 for(
auto it_v = it_u+1; it_v != points.end(); ++it_v, ++idx_v)
72 fil = distance(*it_u,*it_v);
73 if(fil <= threshold) {
74 edges.emplace_back(idx_u,idx_v);
75 edges_fil.push_back(fil);
81 Graph_t skel_graph( edges.begin()
86 auto vertex_prop = boost::get(vertex_filtration_t(),skel_graph);
88 boost::graph_traits<Graph_t>::vertex_iterator vi, vi_end;
89 for ( tie(vi, vi_end) = boost::vertices(skel_graph);
91 { boost::put(vertex_prop, *vi, 0.); }
96 #endif // GUDHI_GRAPH_SIMPLICIAL_COMPLEX_FILTRATION_TAG_H