diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-03-07 14:04:36 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-03-07 14:04:36 +0000 |
commit | 1566e2702deb978d6b04ee2add39a0245df3b477 (patch) | |
tree | 340c27864d442f68f1f88767affcb5d23d818634 /src/Witness_complex/test/test_simple_witness_complex.cpp | |
parent | bd9f1b2e9d21590288dc58980e991d2b687ce025 (diff) |
Remove Kdtree include in Witness_complex.h and Strong_witness_complex.h
Seperate tests using euclidean witness (requires CGAL >= 4.6) and simple tests
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2165 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: f5482e2331d59e60757e7b120e98cfcf97699f30
Diffstat (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp')
-rw-r--r-- | src/Witness_complex/test/test_simple_witness_complex.cpp | 156 |
1 files changed, 37 insertions, 119 deletions
diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index bb1df72d..9e3509d3 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -3,133 +3,51 @@ #include <boost/test/unit_test.hpp> #include <boost/mpl/list.hpp> -#include <CGAL/Epick_d.h> - #include <gudhi/Simplex_tree.h> #include <gudhi/Witness_complex.h> -#include <gudhi/Euclidean_witness_complex.h> -#include <gudhi/Strong_witness_complex.h> -#include <gudhi/Euclidean_strong_witness_complex.h> - -#include <gudhi/Kd_tree_search.h> #include <iostream> -#include <ctime> #include <vector> +#include <utility> -typedef Gudhi::Simplex_tree<> Simplex_tree; -typedef typename Simplex_tree::Vertex_handle Vertex_handle; -typedef std::vector< Vertex_handle > typeVectorVertex; -typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> Kernel; -typedef typename Kernel::FT FT; -typedef typename Kernel::Point_d Point_d; -typedef Gudhi::witness_complex::Euclidean_witness_complex<Kernel> EuclideanWitnessComplex; -typedef Gudhi::witness_complex::Euclidean_strong_witness_complex<Kernel> EuclideanStrongWitnessComplex; - -typedef std::vector<Point_d> Point_range; -typedef Gudhi::spatial_searching::Kd_tree_search<Kernel, Point_range> Kd_tree; -typedef Kd_tree::INS_range Nearest_landmark_range; -typedef std::vector<Nearest_landmark_range> Nearest_landmark_table; -typedef Gudhi::witness_complex::Witness_complex<Nearest_landmark_table> WitnessComplex; -typedef Gudhi::witness_complex::Strong_witness_complex<Nearest_landmark_table> StrongWitnessComplex; - - -/* All landmarks and witnesses are taken on the grid in the following manner. - LWLWL - WW.WW - L...L - WW.WW - LWLWL - - Witness complex consists of 8 vertices, 12 edges and 4 triangles - */ BOOST_AUTO_TEST_CASE(simple_witness_complex) { - Simplex_tree complex, relaxed_complex, strong_relaxed_complex, strong_relaxed_complex2; - Simplex_tree complex_ne, relaxed_complex_ne, strong_relaxed_complex_ne, strong_relaxed_complex2_ne; - - Point_range witnesses, landmarks; - - landmarks.push_back(Point_d(std::vector<FT>{-2,-2})); - landmarks.push_back(Point_d(std::vector<FT>{-2, 0})); - landmarks.push_back(Point_d(std::vector<FT>{-2, 2})); - landmarks.push_back(Point_d(std::vector<FT>{ 0,-2})); - landmarks.push_back(Point_d(std::vector<FT>{ 0, 2})); - landmarks.push_back(Point_d(std::vector<FT>{ 2,-2})); - landmarks.push_back(Point_d(std::vector<FT>{ 2, 0})); - landmarks.push_back(Point_d(std::vector<FT>{ 2, 2})); - witnesses.push_back(Point_d(std::vector<FT>{-2,-1})); - witnesses.push_back(Point_d(std::vector<FT>{-2, 1})); - witnesses.push_back(Point_d(std::vector<FT>{-1,-2})); - witnesses.push_back(Point_d(std::vector<FT>{-1,-1})); - witnesses.push_back(Point_d(std::vector<FT>{-1, 1})); - witnesses.push_back(Point_d(std::vector<FT>{-1, 2})); - witnesses.push_back(Point_d(std::vector<FT>{ 1,-2})); - witnesses.push_back(Point_d(std::vector<FT>{ 1,-1})); - witnesses.push_back(Point_d(std::vector<FT>{ 1, 1})); - witnesses.push_back(Point_d(std::vector<FT>{ 1, 2})); - witnesses.push_back(Point_d(std::vector<FT>{ 2,-1})); - witnesses.push_back(Point_d(std::vector<FT>{ 2, 1})); - - Kd_tree landmark_tree(landmarks); - Nearest_landmark_table nearest_landmark_table; - for (auto w: witnesses) - nearest_landmark_table.push_back(landmark_tree.query_incremental_nearest_neighbors(w)); - - // Weak witness complex: Euclidean version - EuclideanWitnessComplex eucl_witness_complex(landmarks, - witnesses); - eucl_witness_complex.create_complex(complex, 0); - - std::cout << "complex.num_simplices() = " << complex.num_simplices() << std::endl; - BOOST_CHECK(complex.num_simplices() == 24); - - eucl_witness_complex.create_complex(relaxed_complex, 8.01); - - std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; - BOOST_CHECK(relaxed_complex.num_simplices() == 239); - // The corner simplex {0,2,5,7} and its cofaces are missing. - - // Weak witness complex: non-Euclidean version - WitnessComplex witness_complex(nearest_landmark_table); - witness_complex.create_complex(complex_ne, 0); - - std::cout << "complex.num_simplices() = " << complex_ne.num_simplices() << std::endl; - BOOST_CHECK(complex_ne.num_simplices() == 24); - - witness_complex.create_complex(relaxed_complex_ne, 8.01); - - std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex_ne.num_simplices() << std::endl; - BOOST_CHECK(relaxed_complex_ne.num_simplices() == 239); - - - // Strong complex : Euclidean version - EuclideanStrongWitnessComplex eucl_strong_witness_complex(landmarks, - witnesses); - - eucl_strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); - eucl_strong_witness_complex.create_complex(strong_relaxed_complex2, 9.1, 2); - - std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex.num_simplices() << std::endl; - BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); - - std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; - BOOST_CHECK(strong_relaxed_complex2.num_simplices() == 92); - - - // Strong complex : non-Euclidean version - StrongWitnessComplex strong_witness_complex(nearest_landmark_table); - - strong_witness_complex.create_complex(strong_relaxed_complex_ne, 9.1); - strong_witness_complex.create_complex(strong_relaxed_complex2_ne, 9.1, 2); - - std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex_ne.num_simplices() << std::endl; - BOOST_CHECK(strong_relaxed_complex_ne.num_simplices() == 239); - - std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2_ne.num_simplices() << std::endl; - BOOST_CHECK(strong_relaxed_complex2_ne.num_simplices() == 92); - + using Nearest_landmark_range = std::vector<std::pair<std::size_t, double>>; + using Nearest_landmark_table = std::vector<Nearest_landmark_range>; + using Witness_complex = Gudhi::witness_complex::Witness_complex<Nearest_landmark_table>; + using Simplex_tree = Gudhi::Simplex_tree<>; + + Simplex_tree stree; + Nearest_landmark_table nlt; + + // Example contains 5 witnesses and 5 landmarks + Nearest_landmark_range w0 = {std::make_pair(0, 0), std::make_pair(1, 1), std::make_pair(2, 2), + std::make_pair(3, 3), std::make_pair(4, 4)}; nlt.push_back(w0); + Nearest_landmark_range w1 = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(3, 2), + std::make_pair(4, 3), std::make_pair(0, 4)}; nlt.push_back(w1); + Nearest_landmark_range w2 = {std::make_pair(2, 0), std::make_pair(3, 1), std::make_pair(4, 2), + std::make_pair(0, 3), std::make_pair(1, 4)}; nlt.push_back(w2); + Nearest_landmark_range w3 = {std::make_pair(3, 0), std::make_pair(4, 1), std::make_pair(0, 2), + std::make_pair(1, 3), std::make_pair(2, 4)}; nlt.push_back(w3); + Nearest_landmark_range w4 = {std::make_pair(4, 0), std::make_pair(0, 1), std::make_pair(1, 2), + std::make_pair(2, 3), std::make_pair(3, 4)}; nlt.push_back(w4); + + Witness_complex witness_complex(nlt); + BOOST_CHECK(witness_complex.create_complex(stree, 4.1)); + + std::cout << "Number of simplices: " << stree.num_simplices() << std::endl; + BOOST_CHECK(stree.num_simplices() == 31); + + // Check when complex not empty + BOOST_CHECK(!witness_complex.create_complex(stree, 4.1)); + + // Check when max_alpha_square negative + Simplex_tree stree2; + BOOST_CHECK(!witness_complex.create_complex(stree2, -0.02)); + + witness_complex.create_complex(stree2, 4.1, 2); + std::cout << "Number of simplices: " << stree2.num_simplices() << std::endl; + BOOST_CHECK(stree2.num_simplices() == 25); - // 8 vertices, 28 edges, 56 triangles } |