23 #ifndef STRONG_WITNESS_COMPLEX_H_ 24 #define STRONG_WITNESS_COMPLEX_H_ 26 #include <gudhi/Active_witness/Active_witness.h> 35 namespace witness_complex {
48 template<
class Nearest_landmark_table_ >
51 typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range;
52 typedef std::size_t Witness_id;
53 typedef std::size_t Landmark_id;
54 typedef std::pair<Landmark_id, double> Id_distance_pair;
55 typedef Active_witness<Id_distance_pair, Nearest_landmark_range> ActiveWitness;
56 typedef std::list< ActiveWitness > ActiveWitnessList;
57 typedef std::vector< Landmark_id > typeVectorVertex;
58 typedef std::vector<Nearest_landmark_range> Nearest_landmark_table_internal;
59 typedef Landmark_id Vertex_handle;
62 Nearest_landmark_table_internal nearest_landmark_table_;
83 : nearest_landmark_table_(std::begin(nearest_landmark_table), std::end(nearest_landmark_table)) {
95 template <
typename SimplicialComplexForWitness >
97 double max_alpha_square,
98 Landmark_id limit_dimension = std::numeric_limits<Landmark_id>::max())
const {
99 Landmark_id complex_dim = 0;
101 std::cerr <<
"Strong witness complex cannot create complex - complex is not empty.\n";
104 if (max_alpha_square < 0) {
105 std::cerr <<
"Strong witness complex cannot create complex - squared relaxation parameter must be " 106 <<
"non-negative.\n";
109 for (
auto w : nearest_landmark_table_) {
111 typeVectorVertex simplex;
112 typename ActiveWitness::iterator aw_it = aw.begin();
113 float lim_dist2 = aw.begin()->second + max_alpha_square;
114 while ((Landmark_id)simplex.size() <= limit_dimension && aw_it != aw.end() && aw_it->second < lim_dist2) {
115 simplex.push_back(aw_it->first);
120 typeVectorVertex& vertices = simplex;
121 while (aw_it != aw.end() && aw_it->second < lim_dist2) {
122 typeVectorVertex facet = {};
123 add_all_faces_of_dimension(limit_dimension, vertices, vertices.begin(), aw_it,
124 aw_it->second - aw.begin()->second, facet, complex);
125 vertices.push_back(aw_it->first);
128 if ((Landmark_id)simplex.size() - 1 > complex_dim)
129 complex_dim = simplex.size() - 1;
142 template <
typename SimplicialComplexForWitness >
143 void add_all_faces_of_dimension(Landmark_id dim,
144 typeVectorVertex& vertices,
145 typename typeVectorVertex::iterator curr_it,
146 typename ActiveWitness::iterator aw_it,
147 double filtration_value,
148 typeVectorVertex& simplex,
151 while (curr_it != vertices.end()) {
152 simplex.push_back(*curr_it);
154 add_all_faces_of_dimension(dim-1,
162 add_all_faces_of_dimension(dim,
170 }
else if (dim == 0) {
171 simplex.push_back(aw_it->first);
182 #endif // STRONG_WITNESS_COMPLEX_H_ std::size_t num_vertices()
The concept SimplicialComplexForWitness describes the requirements for a type to implement a simplici...
Definition: SimplicialComplexForWitness.h:34
Definition: SimplicialComplexForAlpha.h:26
Strong_witness_complex(Nearest_landmark_table_ const &nearest_landmark_table)
Initializes member variables before constructing simplicial complex.
Definition: Strong_witness_complex.h:82
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...
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:96
Constructs strong witness complex for a given table of nearest landmarks with respect to witnesses...
Definition: Strong_witness_complex.h:49