26 #include <gudhi/Graph_matching.h> 36 namespace persistence_diagram {
38 double bottleneck_distance_approx(Persistence_graph& g,
double e) {
39 double b_lower_bound = 0.;
40 double b_upper_bound = g.diameter_bound();
41 const double alpha = std::pow(g.size(), 1. / 5.);
43 Graph_matching biggest_unperfect(g);
44 while (b_upper_bound - b_lower_bound > 2 * e) {
45 volatile double step = b_lower_bound + (b_upper_bound - b_lower_bound) / alpha;
46 if (step <= b_lower_bound || step >= b_upper_bound)
49 while (m.multi_augment()) {}
51 m = biggest_unperfect;
54 biggest_unperfect = m;
58 return (b_lower_bound + b_upper_bound) / 2.;
61 double bottleneck_distance_exact(Persistence_graph& g) {
62 std::vector<double> sd = g.sorted_distances();
63 long lower_bound_i = 0;
64 long upper_bound_i = sd.size() - 1;
65 const double alpha = std::pow(g.size(), 1. / 5.);
67 Graph_matching biggest_unperfect(g);
68 while (lower_bound_i != upper_bound_i) {
69 long step = lower_bound_i +
static_cast<long> ((upper_bound_i - lower_bound_i - 1) / alpha);
71 while (m.multi_augment()) {}
73 m = biggest_unperfect;
76 biggest_unperfect = m;
77 lower_bound_i = step + 1;
80 return sd.at(lower_bound_i);
102 template<
typename Persistence_diagram1,
typename Persistence_diagram2>
104 double e = (std::numeric_limits<double>::min)()) {
105 Persistence_graph g(diag1, diag2, e);
106 if (g.bottleneck_alive() == std::numeric_limits<double>::infinity())
107 return std::numeric_limits<double>::infinity();
108 return (std::max)(g.bottleneck_alive(), e == 0. ? bottleneck_distance_exact(g) : bottleneck_distance_approx(g, e));
115 #endif // BOTTLENECK_H_ Definition: SimplicialComplexForAlpha.h:26
double bottleneck_distance(const Persistence_diagram1 &diag1, const Persistence_diagram2 &diag2, double e=(std::numeric_limits< double >::min)())
Function to compute the Bottleneck distance between two persistence diagrams.
Definition: Bottleneck.h:103