11 #ifndef STRONG_WITNESS_COMPLEX_H_
12 #define STRONG_WITNESS_COMPLEX_H_
14 #include <gudhi/Active_witness/Active_witness.h>
23 namespace witness_complex {
39 template<
class Nearest_landmark_table_ >
42 typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range;
43 typedef std::size_t Witness_id;
44 typedef std::size_t Landmark_id;
45 typedef std::pair<Landmark_id, double> Id_distance_pair;
47 typedef std::list< ActiveWitness > ActiveWitnessList;
48 typedef std::vector< Landmark_id > typeVectorVertex;
49 typedef std::vector<Nearest_landmark_range> Nearest_landmark_table_internal;
50 typedef Landmark_id Vertex_handle;
53 Nearest_landmark_table_internal nearest_landmark_table_;
74 : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
86 template <
typename SimplicialComplexForWitness >
88 double max_alpha_square,
89 Landmark_id limit_dimension = std::numeric_limits<Landmark_id>::max())
const {
90 Landmark_id complex_dim = 0;
92 std::cerr <<
"Strong witness complex cannot create complex - complex is not empty.\n";
95 if (max_alpha_square < 0) {
96 std::cerr <<
"Strong witness complex cannot create complex - squared relaxation parameter must be "
100 for (
auto w : nearest_landmark_table_) {
102 typeVectorVertex simplex;
104 float lim_dist2 = aw.begin()->second + max_alpha_square;
105 while ((Landmark_id)simplex.size() <= limit_dimension && aw_it != aw.end() && aw_it->second < lim_dist2) {
106 simplex.push_back(aw_it->first);
111 typeVectorVertex& vertices = simplex;
112 while (aw_it != aw.end() && aw_it->second < lim_dist2) {
113 typeVectorVertex facet = {};
114 add_all_faces_of_dimension(limit_dimension, vertices, vertices.begin(), aw_it,
115 aw_it->second - aw.begin()->second, facet, complex);
116 vertices.push_back(aw_it->first);
119 if ((Landmark_id)simplex.size() - 1 > complex_dim)
120 complex_dim = simplex.size() - 1;
133 template <
typename SimplicialComplexForWitness >
134 void add_all_faces_of_dimension(Landmark_id dim,
135 typeVectorVertex& vertices,
136 typename typeVectorVertex::iterator curr_it,
137 typename ActiveWitness::iterator aw_it,
138 double filtration_value,
139 typeVectorVertex& simplex,
142 while (curr_it != vertices.end()) {
143 simplex.push_back(*curr_it);
145 add_all_faces_of_dimension(dim-1,
153 add_all_faces_of_dimension(dim,
161 }
else if (dim == 0) {
162 simplex.push_back(aw_it->first);
Iterator in the nearest landmark list.
Definition: Active_witness_iterator.h:34
Class representing a list of nearest neighbors to a given witness.
Definition: Active_witness.h:27
Constructs strong witness complex for a given table of nearest landmarks with respect to witnesses.
Definition: Strong_witness_complex.h:40
bool create_complex(SimplicialComplexForWitness &complex, double max_alpha_square, Landmark_id limit_dimension=std::numeric_limits< Landmark_id >::max()) const
Outputs the strong witness complex of relaxation 'max_alpha_square' in a simplicial complex data stru...
Definition: Strong_witness_complex.h:87
Strong_witness_complex(Nearest_landmark_table_ const &nearest_landmark_table)
Initializes member variables before constructing simplicial complex.
Definition: Strong_witness_complex.h:73
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
The concept SimplicialComplexForWitness describes the requirements for a type to implement a simplici...
Definition: SimplicialComplexForWitness.h:22
std::size_t num_vertices()
Insertion_result_type insert_simplex_and_subfaces(Input_vertex_range const &vertex_range, Filtration_value filtration)
Inserts a simplex and all its faces with vertices from a given range 'vertex_range' in the simplicial...