blob: 3a0064dc8a561fc75e289da686a852e541252e87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#ifndef FILTERED_TOPLEX_MAP_H
#define FILTERED_TOPLEX_MAP_H
#include <gudhi/Toplex_map.h>
#include <limits>
#define filtration_upper_bound std::numeric_limits<Filtration_value>::max()
namespace Gudhi {
class Filtered_toplex_map {
public:
typedef double Filtration_value;
template <typename Input_vertex_range>
std::pair<Simplex, bool> insert_simplex_and_subfaces(const Input_vertex_range &vertex_range, Filtration_value f = filtration_upper_bound);
template <typename Input_vertex_range>
Filtration_value filtration(const Input_vertex_range &vertex_range) const;
template <typename Input_vertex_range>
bool membership(const Input_vertex_range &vertex_range) const;
protected:
std::unordered_map<Filtration_value, Toplex_map> toplex_maps;
};
template <typename Input_vertex_range>
std::pair<Simplex, bool> Filtered_toplex_map::insert_simplex_and_subfaces(const Input_vertex_range &vertex_range, Filtration_value f){
Simplex s(vertex_range.begin(),vertex_range.end());
if(membership(s)) return make_pair(s,false);
if(!toplex_maps.count(f)) toplex_maps.emplace(f,Toplex_map());
toplex_maps.at(f).insert_simplex(vertex_range);
return make_pair(s,true);
}
template <typename Input_vertex_range>
Filtered_toplex_map::Filtration_value Filtered_toplex_map::filtration(const Input_vertex_range &vertex_range) const{
for(auto kv : toplex_maps)
if(kv.second.membership(vertex_range))
return kv.first;
return filtration_upper_bound;
}
template <typename Input_vertex_range>
bool Filtered_toplex_map::membership(const Input_vertex_range &vertex_range) const{
for(auto kv : toplex_maps)
if(kv.second.membership(vertex_range))
return true;
return false;
}
} //namespace Gudhi
#endif /* FILTERED_TOPLEX_MAP_H */
|