summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-11-12 16:26:05 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-11-12 16:26:05 +0000
commit8881190bccba9da4af0a07c701369099fd7f2277 (patch)
treea215efb479896620d3973af26c65595e85064e1a /src/Alpha_complex/test/Alpha_complex_unit_test.cpp
parent493372a01e24220d16ef0405eb7cdc4bbe96fe1c (diff)
code review fix
prune_above_filtration and remove_maximal_simplex in Simplex_tree.h make_filtration_non_decreasing and rec_make_filtration_non_decreasing in Simplex_tree.h git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@910 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a20c9da65a5a3294e42ad2dd45a399d77fb5ad30
Diffstat (limited to 'src/Alpha_complex/test/Alpha_complex_unit_test.cpp')
-rw-r--r--src/Alpha_complex/test/Alpha_complex_unit_test.cpp54
1 files changed, 40 insertions, 14 deletions
diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
index f64a8ea9..2912019d 100644
--- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
+++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
@@ -88,20 +88,9 @@ BOOST_AUTO_TEST_CASE(ALPHA_DOC_OFF_file_filtered) {
std::cout << "alpha_complex_from_file.num_vertices()=" << alpha_complex_from_file.num_vertices() << std::endl;
BOOST_CHECK(alpha_complex_from_file.num_vertices() == NUMBER_OF_VERTICES);
- const int NUMBER_OF_SIMPLICES = 25;
+ const int NUMBER_OF_SIMPLICES = 23;
std::cout << "alpha_complex_from_file.num_simplices()=" << alpha_complex_from_file.num_simplices() << std::endl;
BOOST_CHECK(alpha_complex_from_file.num_simplices() == NUMBER_OF_SIMPLICES);
-
- int num_filtered_simplices = 0;
- for (auto f_simplex : alpha_complex_from_file.filtration_simplex_range()) {
- if (alpha_complex_from_file.filtration(f_simplex) <= alpha_complex_from_file.filtration()) {
- num_filtered_simplices++;
- }
- }
- const int NUMBER_OF_FILTERED_SIMPLICES = 23;
- std::cout << "num_filtered_simplices=" << num_filtered_simplices << std::endl;
- BOOST_CHECK(num_filtered_simplices == NUMBER_OF_FILTERED_SIMPLICES);
-
}
bool are_almost_the_same(float a, float b) {
@@ -140,8 +129,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) {
// ----------------------------------------------------------------------------
// Init of an alpha complex from the list of points
// ----------------------------------------------------------------------------
- double max_alpha_square_value = 1e10;
- Gudhi::alphacomplex::Alpha_complex<Kernel_s> alpha_complex_from_points(points, max_alpha_square_value);
+ Gudhi::alphacomplex::Alpha_complex<Kernel_s> alpha_complex_from_points(points);
std::cout << "========== Alpha_complex_from_points ==========" << std::endl;
@@ -210,4 +198,42 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) {
BOOST_CHECK_THROW (alpha_complex_from_points.get_point(4), std::out_of_range);
BOOST_CHECK_THROW (alpha_complex_from_points.get_point(-1), std::out_of_range);
BOOST_CHECK_THROW (alpha_complex_from_points.get_point(1234), std::out_of_range);
+
+ // Test after prune_above_filtration
+ alpha_complex_from_points.prune_above_filtration(0.6);
+ // Another way to check num_simplices
+ std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ num_simplices = 0;
+ for (auto f_simplex : alpha_complex_from_points.filtration_simplex_range()) {
+ num_simplices++;
+ std::cout << " ( ";
+ for (auto vertex : alpha_complex_from_points.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> " << "[" << alpha_complex_from_points.filtration(f_simplex) << "] ";
+ std::cout << std::endl;
+ }
+ BOOST_CHECK(num_simplices == 10);
+ std::cout << "alpha_complex_from_points.num_simplices()=" << alpha_complex_from_points.num_simplices() << std::endl;
+ BOOST_CHECK(alpha_complex_from_points.num_simplices() == 10);
+
+ std::cout << "alpha_complex_from_points.dimension()=" << alpha_complex_from_points.dimension() << std::endl;
+ BOOST_CHECK(alpha_complex_from_points.dimension() == 4);
+ std::cout << "alpha_complex_from_points.num_vertices()=" << alpha_complex_from_points.num_vertices() << std::endl;
+ BOOST_CHECK(alpha_complex_from_points.num_vertices() == 4);
+
+ for (auto f_simplex : alpha_complex_from_points.filtration_simplex_range()) {
+ switch (alpha_complex_from_points.dimension(f_simplex)) {
+ case 0:
+ BOOST_CHECK(are_almost_the_same(alpha_complex_from_points.filtration(f_simplex), 0.0));
+ break;
+ case 1:
+ BOOST_CHECK(are_almost_the_same(alpha_complex_from_points.filtration(f_simplex), 1.0/2.0));
+ break;
+ default:
+ BOOST_CHECK(false); // Shall not happen
+ break;
+ }
+ }
+
}