summaryrefslogtreecommitdiff
path: root/src/Bottleneck/test/bottleneck_unit_test.cpp
blob: c60f5d8a917c1202cd06726241d00fd01e22bb2b (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
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "bottleneck"
#include <boost/test/unit_test.hpp>

#include "gudhi/Graph_matching.h"
#include <iostream>

using namespace Gudhi::bottleneck;

BOOST_AUTO_TEST_CASE(random_diagrams) {
  int n = 100;
  // Random construction
  std::vector< std::pair<double, double> > v1, v2;
  for (int i = 0; i < n; i++) {
    int a = rand() % n;
    v1.emplace_back(a, a + rand() % (n - a));
    int b = rand() % n;
    v2.emplace_back(b, b + rand() % (n - b));
  }
  // v1 and v2 are persistence diagrams containing each 100 randoms points.
  double b = bottleneck_distance(v1, v2, 0);
  //
  std::cout << b << std::endl;
  const double EXPECTED_DISTANCE = 98.5;
  BOOST_CHECK(b == EXPECTED_DISTANCE);
}