summaryrefslogtreecommitdiff
path: root/src/Toplex_map
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-10-12 12:42:11 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-10-12 12:42:11 +0000
commit004ff4cfc01d1c8128a2b39092dbfbc25149069d (patch)
treee13fc9c4c59bc101a249d427594c39f3c45ebb85 /src/Toplex_map
parent4e11105c6ab550f664699fc25b71d06884fa2bd3 (diff)
Rename num_simplices num_maximal_simplices
Make unitary tests working git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3947 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: eddea297f7cf6a0fd172ceaa3fbb28b6e3cb2e63
Diffstat (limited to 'src/Toplex_map')
-rw-r--r--src/Toplex_map/benchmark/CMakeLists.txt1
-rw-r--r--src/Toplex_map/example/CMakeLists.txt5
-rw-r--r--src/Toplex_map/include/gudhi/Lazy_Toplex_map.h5
-rw-r--r--src/Toplex_map/include/gudhi/Toplex_map.h4
-rw-r--r--src/Toplex_map/test/CMakeLists.txt14
-rw-r--r--src/Toplex_map/test/toplex_map_unit_test.cpp109
6 files changed, 77 insertions, 61 deletions
diff --git a/src/Toplex_map/benchmark/CMakeLists.txt b/src/Toplex_map/benchmark/CMakeLists.txt
index 2c67892c..c2f216bc 100644
--- a/src/Toplex_map/benchmark/CMakeLists.txt
+++ b/src/Toplex_map/benchmark/CMakeLists.txt
@@ -1,4 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
project(Toplex_map_benchmark)
add_executable(toplex_map_chrono chrono.cpp)
diff --git a/src/Toplex_map/example/CMakeLists.txt b/src/Toplex_map/example/CMakeLists.txt
index 051d7bcd..58185fd5 100644
--- a/src/Toplex_map/example/CMakeLists.txt
+++ b/src/Toplex_map/example/CMakeLists.txt
@@ -1,5 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
project(Toplex_map_examples)
-add_executable(Toplex_map_example_simple Simple_toplex_map.cpp)
-add_executable(Toplex_map_example_from_cliques_of_graph Toplex_map_from_cliques_of_graph.cpp)
+#add_executable(Toplex_map_example_simple Simple_toplex_map.cpp)
+#add_executable(Toplex_map_example_from_cliques_of_graph Toplex_map_from_cliques_of_graph.cpp)
diff --git a/src/Toplex_map/include/gudhi/Lazy_Toplex_map.h b/src/Toplex_map/include/gudhi/Lazy_Toplex_map.h
index 25281998..ea10d390 100644
--- a/src/Toplex_map/include/gudhi/Lazy_Toplex_map.h
+++ b/src/Toplex_map/include/gudhi/Lazy_Toplex_map.h
@@ -3,7 +3,6 @@
#include <gudhi/Toplex_map.h>
#include <boost/heap/fibonacci_heap.hpp>
-#include <cmath>
namespace Gudhi {
@@ -67,7 +66,7 @@ public:
/** \brief Number of simplices stored.
* \ingroup toplex_map */
- std::size_t num_simplices() const;
+ std::size_t num_maximal_simplices() const;
std::unordered_map<Vertex, std::size_t> gamma0_lbounds;
@@ -254,7 +253,7 @@ void Lazy_Toplex_map::clean(const Vertex v){
insert_simplex(*sptr);
}
-std::size_t Lazy_Toplex_map::num_simplices() const{
+std::size_t Lazy_Toplex_map::num_maximal_simplices() const{
return size;
}
diff --git a/src/Toplex_map/include/gudhi/Toplex_map.h b/src/Toplex_map/include/gudhi/Toplex_map.h
index 73d2c63d..5a6c7dbf 100644
--- a/src/Toplex_map/include/gudhi/Toplex_map.h
+++ b/src/Toplex_map/include/gudhi/Toplex_map.h
@@ -88,7 +88,7 @@ public:
/** \brief Number of maximal simplices.
* \ingroup toplex_map */
- std::size_t num_simplices() const;
+ std::size_t num_maximal_simplices() const;
std::set<Toplex_map::Vertex> unitary_collapse(const Toplex_map::Vertex k, const Toplex_map::Vertex d);
@@ -251,7 +251,7 @@ void Toplex_map::remove_vertex(const Toplex_map::Vertex x){
}
}
-std::size_t Toplex_map::num_simplices() const{
+std::size_t Toplex_map::num_maximal_simplices() const{
return maximal_cofaces(Simplex()).size();
}
diff --git a/src/Toplex_map/test/CMakeLists.txt b/src/Toplex_map/test/CMakeLists.txt
index 5ed55e97..237cfdad 100644
--- a/src/Toplex_map/test/CMakeLists.txt
+++ b/src/Toplex_map/test/CMakeLists.txt
@@ -1,14 +1,8 @@
-cmake_minimum_required(VERSION 2.6)
project(Toplex_map_tests)
-add_executable ( ToplexMapUT toplex_map_unit_test.cpp )
-target_link_libraries(ToplexMapUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+include(GUDHI_test_coverage)
+add_executable( Toplex_map_unit_test toplex_map_unit_test.cpp )
+target_link_libraries(Toplex_map_unit_test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
-# Unitary tests
-add_test(NAME ToplexMapUT
- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/ToplexMapUT
- ${CMAKE_SOURCE_DIR}/src/Toplex_map/test/test.txt
- # XML format for Jenkins xUnit plugin
- --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/ToplexMapUT.xml --log_level=test_suite --report_level=no)
-
+gudhi_add_coverage_test(Toplex_map_unit_test)
diff --git a/src/Toplex_map/test/toplex_map_unit_test.cpp b/src/Toplex_map/test/toplex_map_unit_test.cpp
index c12ad094..2c584c5d 100644
--- a/src/Toplex_map/test/toplex_map_unit_test.cpp
+++ b/src/Toplex_map/test/toplex_map_unit_test.cpp
@@ -1,54 +1,79 @@
#include <iostream>
-#include <gudhi/Filtered_toplex_map.h>
+#include <vector>
+#include <gudhi/Lazy_Toplex_map.h>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "toplex map"
#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
+
+using list_of_tested_variants = boost::mpl::list<Gudhi::Toplex_map, Gudhi::Lazy_Toplex_map>;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(common_toplex_map_functionnalities, Toplex_map, list_of_tested_variants) {
+ using Vertex = typename Toplex_map::Vertex;
+
+ 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};
+
+ Toplex_map K;
+ K.insert_simplex(sigma1);
+ K.insert_simplex(sigma2);
+ K.insert_simplex(sigma3);
+ K.insert_simplex(sigma6);
+ K.insert_simplex(sigma7);
+
+ std::cout << K.num_maximal_simplices();
+
+ BOOST_CHECK(K.membership(sigma4));
+ //BOOST_CHECK(!K.maximality(sigma3));
+ BOOST_CHECK(!K.membership(sigma5));
+ K.insert_simplex(sigma5);
+
+ std::cout << K.num_maximal_simplices();
+
+ BOOST_CHECK(K.membership(sigma5));
+ std::vector<Vertex> sigma9 = {1, 2, 3};
+ std::vector<Vertex> sigma10 = {2, 7};
+ auto r = K.contraction(4,5);
+
+ std::cout << K.num_maximal_simplices();
+
+ sigma9.emplace_back(r);
+ sigma10.emplace_back(r);
+ BOOST_CHECK(!K.membership(sigma6));
+ BOOST_CHECK(K.membership(sigma9));
+ BOOST_CHECK(K.membership(sigma10));
+ K.remove_simplex(sigma10);
+ BOOST_CHECK(!K.membership(sigma10));
-using namespace Gudhi;
-
-typedef Toplex_map::Vertex Vertex;
-
-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(sigma3));
- BOOST_CHECK(!K.membership(sigma5));
- K.insert_simplex(sigma5);
- std::vector<Vertex> sigma9 = {1, 2, 3};
- std::vector<Vertex> sigma10 = {2, 7};
- auto r = K.contraction(4,5);
- sigma9.emplace_back(r);
- sigma10.emplace_back(r);
- BOOST_CHECK(!K.membership(sigma6));
- BOOST_CHECK(K.membership(sigma9));
- BOOST_CHECK(K.membership(sigma10));
}
+BOOST_AUTO_TEST_CASE(toplex_map_maximality) {
+ using Vertex = Gudhi::Toplex_map::Vertex;
+
+ 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 = {4, 5, 3};
+ std::vector<Vertex> sigma5 = {4, 5, 9};
-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.);
+ Gudhi::Toplex_map K;
+ K.insert_simplex(sigma1);
+ K.insert_simplex(sigma2);
+ K.insert_simplex(sigma3);
+ K.insert_simplex(sigma4);
+ K.insert_simplex(sigma5);
+ BOOST_CHECK(K.maximality(sigma1));
+ BOOST_CHECK(K.maximality(sigma2));
+ BOOST_CHECK(!K.maximality(sigma3));
+ BOOST_CHECK(K.maximality(sigma4));
+ BOOST_CHECK(K.maximality(sigma5));
}