summaryrefslogtreecommitdiff
path: root/src/Toplex_map/test/toplex_map_unit_test.cpp
blob: 3f4d96c27d52e15d461f24cd1af27e4688329f37 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <gudhi/Lazy_toplex_map.h>
#include <gudhi/Filtered_toplex_map.h>
#include <gudhi/Fake_simplex_tree.h>

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "toplex map"
#include <boost/test/unit_test.hpp>

using namespace Gudhi;

std::vector<Vertex> sigma1 = {1, 2, 3, 4};
std::vector<Vertex> sigma2 = {5, 2, 3, 6};
std::vector<Vertex> sigma3 = {5};
std::vector<Vertex> sigma4 = {5, 2, 3};
std::vector<Vertex> sigma5 = {5, 2, 7};
std::vector<Vertex> sigma6 = {4, 5, 3};
std::vector<Vertex> sigma7 = {4, 5, 9};
std::vector<Vertex> sigma8 = {1, 2, 3, 6};


BOOST_AUTO_TEST_CASE(toplexmap) {
    Toplex_map K;
    K.insert_simplex(sigma1);
    K.insert_simplex(sigma2);
    K.insert_simplex(sigma3);
    K.insert_simplex(sigma6);
    K.insert_simplex(sigma7);
    BOOST_CHECK(K.membership(sigma4));
    BOOST_CHECK(!K.maximality(sigma5));
    BOOST_CHECK(!K.membership(sigma5));
    K.contraction(4,5);
    BOOST_CHECK(!K.membership(sigma6));
}

BOOST_AUTO_TEST_CASE(ltoplexmap) {
    Lazy_Toplex_map K;
    K.insert_simplex(sigma1);
    K.insert_simplex(sigma2);
    K.insert_simplex(sigma3);
    K.insert_simplex(sigma6);
    K.insert_simplex(sigma7);
    BOOST_CHECK(K.membership(sigma4));
    BOOST_CHECK(!K.membership(sigma5));
    K.contraction(4,5);
    BOOST_CHECK(!K.membership(sigma6));
}

BOOST_AUTO_TEST_CASE(ftoplexmap) {
    Filtered_toplex_map K;
    K.insert_simplex_and_subfaces(sigma1, 2.);
    K.insert_simplex_and_subfaces(sigma2, 2.);
    K.insert_simplex_and_subfaces(sigma6, 1.);
    K.insert_simplex_and_subfaces(sigma7, 1.);
    BOOST_CHECK(K.filtration(sigma4)==2.);
    BOOST_CHECK(K.filtration(sigma3)==1.);
}

/*
BOOST_AUTO_TEST_CASE(toplexmap_candidates) {
    Toplex_map K;
    K.insert_simplex(sigma1);
    K.insert_simplex(sigma2);
    K.remove_simplex(sigma1);
    K.remove_simplex(sigma2);
    auto c = K.candidates();
    BOOST_CHECK(c.count(get_key(sigma1)));
    BOOST_CHECK(c.count(get_key(sigma2)));
    BOOST_CHECK(c.size()==2);
}
*/