From 25f3818f7588b278ea88818dc0a0e4912b28e67d Mon Sep 17 00:00:00 2001 From: anmoreau Date: Tue, 18 Aug 2015 14:47:44 +0000 Subject: Multiple fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/copy_move@741 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c88c6e221ad320b123fc82c7d4f1b26f29204524 --- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 285 ++++++++++++----------- 1 file changed, 147 insertions(+), 138 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index cd690b19..4253e2e4 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -1,15 +1,14 @@ -#define BOOST_TEST_MODULE simplex_tree test -#include -#include -#include #include #include - +#include #include // std::pair, std::make_pair - #include // float comparison #include +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree" +#include + #include "gudhi/graph_simplicial_complex.h" #include "gudhi/reader_utils.h" #include "gudhi/Simplex_tree.h" @@ -21,7 +20,7 @@ typedef std::pair typePairSimplexBool; typedef std::vector typeVectorVertex; typedef std::pair typeSimplex; -const Vertex_handle DEFAULT_VERTEX_HANDLE = (const Vertex_handle) -1; +const Vertex_handle DEFAULT_VERTEX_HANDLE = (const Vertex_handle) - 1; const Filtration_value DEFAULT_FILTRATION_VALUE = (const Filtration_value) 0.0; void test_empty_simplex_tree(typeST& tst) { @@ -40,25 +39,24 @@ void test_iterators_on_empty_simplex_tree(typeST& tst) { std::cout << "Iterator on vertices: " << std::endl; for (auto vertex : tst.complex_vertex_range()) { std::cout << "vertice:" << vertex << std::endl; - BOOST_CHECK(false); // shall be empty + BOOST_CHECK(false); // shall be empty } std::cout << "Iterator on simplices: " << std::endl; for (auto simplex : tst.complex_simplex_range()) { - BOOST_CHECK(simplex != simplex); // shall be empty - to remove warning of non-used simplex + BOOST_CHECK(simplex != simplex); // shall be empty - to remove warning of non-used simplex } std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; for (auto f_simplex : tst.filtration_simplex_range()) { - BOOST_CHECK(false); // shall be empty + BOOST_CHECK(false); // shall be empty std::cout << "test_iterators_on_empty_simplex_tree - filtration=" << tst.filtration(f_simplex) << std::endl; } } -BOOST_AUTO_TEST_CASE( simplex_tree_when_empty ) -{ +BOOST_AUTO_TEST_CASE(simplex_tree_when_empty) { const Filtration_value DEFAULT_FILTRATION_VALUE = 0; // TEST OF DEFAULT CONSTRUCTOR @@ -66,29 +64,28 @@ BOOST_AUTO_TEST_CASE( simplex_tree_when_empty ) std::cout << "TEST OF DEFAULT CONSTRUCTOR" << std::endl; typeST st; - test_empty_simplex_tree (st); + test_empty_simplex_tree(st); - test_iterators_on_empty_simplex_tree (st); + test_iterators_on_empty_simplex_tree(st); // TEST OF EMPTY INSERTION std::cout << "TEST OF EMPTY INSERTION" << std::endl; typeVectorVertex simplexVectorEmpty; BOOST_CHECK(simplexVectorEmpty.empty() == true); typePairSimplexBool returnEmptyValue = st.insert_simplex(simplexVectorEmpty, - DEFAULT_FILTRATION_VALUE); + DEFAULT_FILTRATION_VALUE); BOOST_CHECK(returnEmptyValue.first == typeST::Simplex_handle(NULL)); BOOST_CHECK(returnEmptyValue.second == true); - test_empty_simplex_tree (st); + test_empty_simplex_tree(st); - test_iterators_on_empty_simplex_tree (st); + test_iterators_on_empty_simplex_tree(st); } bool AreAlmostTheSame(float a, float b) { return std::fabs(a - b) < std::numeric_limits::epsilon(); } -BOOST_AUTO_TEST_CASE( simplex_tree_from_file ) -{ +BOOST_AUTO_TEST_CASE(simplex_tree_from_file) { // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF SIMPLEX TREE FROM A FILE" << std::endl; @@ -108,16 +105,15 @@ BOOST_AUTO_TEST_CASE( simplex_tree_from_file ) BOOST_CHECK(st.filtration() == 0.4); int previous_size = 0; - for( auto f_simplex : st.filtration_simplex_range() ) - { + for (auto f_simplex : st.filtration_simplex_range()) { // Size of simplex int size = 0; - for( auto vertex : st.simplex_vertex_range(f_simplex) ) - { + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + (void) vertex; size++; } - BOOST_CHECK(AreAlmostTheSame(st.filtration(f_simplex),(0.1* size))); // Specific test: filtration = 0.1 * simplex_size - BOOST_CHECK(previous_size <= size);// Check list is sorted (because of sorted filtrations in simplex_tree.txt) + BOOST_CHECK(AreAlmostTheSame(st.filtration(f_simplex), (0.1 * size))); // Specific test: filtration = 0.1 * simplex_size + BOOST_CHECK(previous_size <= size); // Check list is sorted (because of sorted filtrations in simplex_tree.txt) previous_size = size; } simplex_tree_stream.close(); @@ -127,14 +123,14 @@ void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int p auto f_simplex = simplexTree.filtration_simplex_range().begin() + pos; std::cout << "test_simplex_tree_contains - filtration=" << simplexTree.filtration(*f_simplex) << "||" << simplex.second << std::endl; - BOOST_CHECK( AreAlmostTheSame(simplexTree.filtration(*f_simplex),simplex.second) ); + BOOST_CHECK(AreAlmostTheSame(simplexTree.filtration(*f_simplex), simplex.second)); int simplexIndex=simplex.first.size()-1; std::sort(simplex.first.begin(), simplex.first.end()); // if the simplex wasn't sorted, the next test could fail for( auto vertex : simplexTree.simplex_vertex_range(*f_simplex) ) { std::cout << "test_simplex_tree_contains - vertex=" << vertex << "||" << simplex.first.at(simplexIndex) << std::endl; - BOOST_CHECK(vertex == simplex.first.at(simplexIndex)); + BOOST_CHECK(vertex == simplex.first.at(simplexIndex)); BOOST_CHECK(simplexIndex >= 0); simplexIndex--; } @@ -142,7 +138,7 @@ void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int p void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValue) { BOOST_CHECK(returnValue.second == true); - typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator BOOST_CHECK(shReturned != typeST::Simplex_handle(NULL)); } @@ -171,8 +167,23 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons BOOST_CHECK(simplexTree.num_simplices() == nb_simplices); } -BOOST_AUTO_TEST_CASE( simplex_tree_insertion ) -{ +void test_cofaces(typeST& st, std::vector v, int dim, std::vector res) { + typeST::Cofaces_simplex_range cofaces; + if (dim == 0) + cofaces = st.star_simplex_range(st.find(v)); + else + cofaces = st.cofaces_simplex_range(st.find(v), dim); + for (auto simplex = cofaces.begin(); simplex != cofaces.end(); ++simplex) { + typeST::Simplex_vertex_range rg = st.simplex_vertex_range(*simplex); + for (auto vertex = rg.begin(); vertex != rg.end(); ++vertex) { + std::cout << "(" << *vertex << ")"; + } + std::cout << std::endl; + BOOST_CHECK(std::find(res.begin(), res.end(), *simplex) != res.end()); + } +} + +BOOST_AUTO_TEST_CASE(simplex_tree_insertion) { const Filtration_value FIRST_FILTRATION_VALUE = 0.1; const Filtration_value SECOND_FILTRATION_VALUE = 0.2; const Filtration_value THIRD_FILTRATION_VALUE = 0.3; @@ -191,88 +202,88 @@ BOOST_AUTO_TEST_CASE( simplex_tree_insertion ) std::cout << " - INSERT 0" << std::endl; typeVectorVertex firstSimplexVector; firstSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( firstSimplexVector.size() == 1 ); + BOOST_CHECK(firstSimplexVector.size() == 1); typeSimplex firstSimplex = std::make_pair( - firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); typePairSimplexBool returnValue = st.insert_simplex(firstSimplex.first, - firstSimplex.second); + firstSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, firstSimplexVector.size(), firstSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)1 ); + BOOST_CHECK(st.num_vertices() == (size_t) 1); // ++ SECOND std::cout << " - INSERT 1" << std::endl; typeVectorVertex secondSimplexVector; secondSimplexVector.push_back(SECOND_VERTEX_HANDLE); - BOOST_CHECK( secondSimplexVector.size() == 1 ); + BOOST_CHECK(secondSimplexVector.size() == 1); typeSimplex secondSimplex = std::make_pair( - secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( secondSimplex.first, secondSimplex.second ); + st.insert_simplex(secondSimplex.first, secondSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, secondSimplexVector.size(), secondSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)2 ); + BOOST_CHECK(st.num_vertices() == (size_t) 2); // ++ THIRD std::cout << " - INSERT (0,1)" << std::endl; typeVectorVertex thirdSimplexVector; thirdSimplexVector.push_back(FIRST_VERTEX_HANDLE); thirdSimplexVector.push_back(SECOND_VERTEX_HANDLE); - BOOST_CHECK( thirdSimplexVector.size() == 2 ); + BOOST_CHECK(thirdSimplexVector.size() == 2); typeSimplex thirdSimplex = std::make_pair( - thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( thirdSimplex.first, thirdSimplex.second ); + st.insert_simplex(thirdSimplex.first, thirdSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, thirdSimplexVector.size(), thirdSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)2 ); // Not incremented !! + BOOST_CHECK(st.num_vertices() == (size_t) 2); // Not incremented !! // ++ FOURTH std::cout << " - INSERT 2" << std::endl; typeVectorVertex fourthSimplexVector; fourthSimplexVector.push_back(THIRD_VERTEX_HANDLE); - BOOST_CHECK( fourthSimplexVector.size() == 1 ); + BOOST_CHECK(fourthSimplexVector.size() == 1); typeSimplex fourthSimplex = std::make_pair( - fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( fourthSimplex.first, fourthSimplex.second ); + st.insert_simplex(fourthSimplex.first, fourthSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, fourthSimplexVector.size(), fourthSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)3 ); + BOOST_CHECK(st.num_vertices() == (size_t) 3); // ++ FIFTH std::cout << " - INSERT (2,0)" << std::endl; typeVectorVertex fifthSimplexVector; fifthSimplexVector.push_back(THIRD_VERTEX_HANDLE); fifthSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( fifthSimplexVector.size() == 2 ); + BOOST_CHECK(fifthSimplexVector.size() == 2); typeSimplex fifthSimplex = std::make_pair( - fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( fifthSimplex.first, fifthSimplex.second ); + st.insert_simplex(fifthSimplex.first, fifthSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, fifthSimplexVector.size(), fifthSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)3 ); // Not incremented !! + BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !! // ++ SIXTH std::cout << " - INSERT (2,1)" << std::endl; typeVectorVertex sixthSimplexVector; sixthSimplexVector.push_back(THIRD_VERTEX_HANDLE); sixthSimplexVector.push_back(SECOND_VERTEX_HANDLE); - BOOST_CHECK( sixthSimplexVector.size() == 2 ); + BOOST_CHECK(sixthSimplexVector.size() == 2); typeSimplex sixthSimplex = std::make_pair( - sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( sixthSimplex.first, sixthSimplex.second ); + st.insert_simplex(sixthSimplex.first, sixthSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, sixthSimplexVector.size(), sixthSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)3 ); // Not incremented !! + BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !! // ++ SEVENTH std::cout << " - INSERT (2,1,0)" << std::endl; @@ -280,61 +291,61 @@ BOOST_AUTO_TEST_CASE( simplex_tree_insertion ) seventhSimplexVector.push_back(THIRD_VERTEX_HANDLE); seventhSimplexVector.push_back(SECOND_VERTEX_HANDLE); seventhSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( seventhSimplexVector.size() == 3 ); + BOOST_CHECK(seventhSimplexVector.size() == 3); typeSimplex seventhSimplex = std::make_pair( - seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE)); + seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( seventhSimplex.first, seventhSimplex.second ); + st.insert_simplex(seventhSimplex.first, seventhSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, seventhSimplexVector.size(), seventhSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)3 ); // Not incremented !! + BOOST_CHECK(st.num_vertices() == (size_t) 3); // Not incremented !! // ++ EIGHTH std::cout << " - INSERT 3" << std::endl; typeVectorVertex eighthSimplexVector; eighthSimplexVector.push_back(FOURTH_VERTEX_HANDLE); - BOOST_CHECK( eighthSimplexVector.size() == 1 ); + BOOST_CHECK(eighthSimplexVector.size() == 1); typeSimplex eighthSimplex = std::make_pair( - eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( eighthSimplex.first, eighthSimplex.second ); + st.insert_simplex(eighthSimplex.first, eighthSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, eighthSimplexVector.size(), eighthSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); + BOOST_CHECK(st.num_vertices() == (size_t) 4); // ++ NINETH std::cout << " - INSERT (3,0)" << std::endl; typeVectorVertex ninethSimplexVector; ninethSimplexVector.push_back(FOURTH_VERTEX_HANDLE); ninethSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( ninethSimplexVector.size() == 2 ); + BOOST_CHECK(ninethSimplexVector.size() == 2); typeSimplex ninethSimplex = std::make_pair( - ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( ninethSimplex.first, ninethSimplex.second ); + st.insert_simplex(ninethSimplex.first, ninethSimplex.second); - test_simplex_tree_insert_returns_true (returnValue); + test_simplex_tree_insert_returns_true(returnValue); set_and_test_simplex_tree_dim_fil(st, ninethSimplexVector.size(), ninethSimplex.second); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); // Not incremented !! + BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! // ++ TENTH std::cout << " - INSERT 0 (already inserted)" << std::endl; typeVectorVertex tenthSimplexVector; tenthSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( tenthSimplexVector.size() == 1 ); + BOOST_CHECK(tenthSimplexVector.size() == 1); typeSimplex tenthSimplex = std::make_pair( - tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); // With a different filtration value + tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); // With a different filtration value returnValue = - st.insert_simplex ( tenthSimplex.first, tenthSimplex.second ); + st.insert_simplex(tenthSimplex.first, tenthSimplex.second); BOOST_CHECK(returnValue.second == false); - typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator BOOST_CHECK(shReturned == typeST::Simplex_handle(NULL)); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); // Not incremented !! - BOOST_CHECK( st.dimension() == dim_max ); - BOOST_CHECK( AreAlmostTheSame(st.filtration(), max_fil) ); + BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! + BOOST_CHECK(st.dimension() == dim_max); + BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); // ++ ELEVENTH std::cout << " - INSERT (2,1,0) (already inserted)" << std::endl; @@ -342,18 +353,18 @@ BOOST_AUTO_TEST_CASE( simplex_tree_insertion ) eleventhSimplexVector.push_back(THIRD_VERTEX_HANDLE); eleventhSimplexVector.push_back(SECOND_VERTEX_HANDLE); eleventhSimplexVector.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( eleventhSimplexVector.size() == 3 ); + BOOST_CHECK(eleventhSimplexVector.size() == 3); typeSimplex eleventhSimplex = std::make_pair( - eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); + eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); returnValue = - st.insert_simplex ( eleventhSimplex.first, eleventhSimplex.second ); + st.insert_simplex(eleventhSimplex.first, eleventhSimplex.second); BOOST_CHECK(returnValue.second == false); - shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator BOOST_CHECK(shReturned == typeST::Simplex_handle(NULL)); - BOOST_CHECK( st.num_vertices() == (size_t)4 );// Not incremented !! - BOOST_CHECK( st.dimension() == dim_max ); - BOOST_CHECK( AreAlmostTheSame(st.filtration(), max_fil) ); + BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! + BOOST_CHECK(st.dimension() == dim_max); + BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); /* Inserted simplex: */ /* 1 */ @@ -373,43 +384,40 @@ BOOST_AUTO_TEST_CASE( simplex_tree_insertion ) // [0.3] 2 1 0 // !! Be careful, simplex are sorted by filtration value on insertion !! std::cout << "simplex_tree_insertion - first - 0" << std::endl; - test_simplex_tree_contains(st, firstSimplex, 0);// (0) -> 0 + test_simplex_tree_contains(st, firstSimplex, 0); // (0) -> 0 std::cout << "simplex_tree_insertion - second - 1" << std::endl; - test_simplex_tree_contains(st, secondSimplex, 1);// (1) -> 1 + test_simplex_tree_contains(st, secondSimplex, 1); // (1) -> 1 std::cout << "simplex_tree_insertion - third - 4" << std::endl; - test_simplex_tree_contains(st, thirdSimplex, 4);// (0,1) -> 4 + test_simplex_tree_contains(st, thirdSimplex, 4); // (0,1) -> 4 std::cout << "simplex_tree_insertion - fourth - 2" << std::endl; - test_simplex_tree_contains(st, fourthSimplex, 2);// (2) -> 2 + test_simplex_tree_contains(st, fourthSimplex, 2); // (2) -> 2 std::cout << "simplex_tree_insertion - fifth - 5" << std::endl; - test_simplex_tree_contains(st, fifthSimplex, 5);// (2,0) -> 5 + test_simplex_tree_contains(st, fifthSimplex, 5); // (2,0) -> 5 std::cout << "simplex_tree_insertion - sixth - 6" << std::endl; - test_simplex_tree_contains(st, sixthSimplex, 6);//(2,1) -> 6 + test_simplex_tree_contains(st, sixthSimplex, 6); //(2,1) -> 6 std::cout << "simplex_tree_insertion - seventh - 8" << std::endl; - test_simplex_tree_contains(st, seventhSimplex, 8);// (2,1,0) -> 8 + test_simplex_tree_contains(st, seventhSimplex, 8); // (2,1,0) -> 8 std::cout << "simplex_tree_insertion - eighth - 3" << std::endl; - test_simplex_tree_contains(st, eighthSimplex, 3);// (3) -> 3 + test_simplex_tree_contains(st, eighthSimplex, 3); // (3) -> 3 std::cout << "simplex_tree_insertion - nineth - 7" << std::endl; - test_simplex_tree_contains(st, ninethSimplex, 7);// (3,0) -> 7 + test_simplex_tree_contains(st, ninethSimplex, 7); // (3,0) -> 7 // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; - for( auto f_simplex : st.filtration_simplex_range() ) - { + for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for( auto vertex : st.simplex_vertex_range(f_simplex) ) - { - std::cout << (int)vertex << " "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; } std::cout << std::endl; } } -BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) -{ - Vertex_handle FIRST_VERTEX_HANDLE = (Vertex_handle)0; +BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) { + Vertex_handle FIRST_VERTEX_HANDLE = (Vertex_handle) 0; Vertex_handle SECOND_VERTEX_HANDLE = (Vertex_handle) 1; Vertex_handle THIRD_VERTEX_HANDLE = (Vertex_handle) 2; Vertex_handle FOURTH_VERTEX_HANDLE = (Vertex_handle) 3; @@ -429,39 +437,39 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) SimplexVector1.push_back(THIRD_VERTEX_HANDLE); SimplexVector1.push_back(SECOND_VERTEX_HANDLE); SimplexVector1.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector1.size() == 3 ); - st.insert_simplex_and_subfaces ( SimplexVector1 ); + BOOST_CHECK(SimplexVector1.size() == 3); + st.insert_simplex_and_subfaces(SimplexVector1); - BOOST_CHECK( st.num_vertices() == (size_t)3 ); // +3 (2, 1 and 0 are not existing) + BOOST_CHECK(st.num_vertices() == (size_t) 3); // +3 (2, 1 and 0 are not existing) // ++ SECOND std::cout << " - INSERT 3" << std::endl; typeVectorVertex SimplexVector2; SimplexVector2.push_back(FOURTH_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector2.size() == 1 ); - st.insert_simplex_and_subfaces ( SimplexVector2 ); + BOOST_CHECK(SimplexVector2.size() == 1); + st.insert_simplex_and_subfaces(SimplexVector2); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); // +1 (3 is not existing) + BOOST_CHECK(st.num_vertices() == (size_t) 4); // +1 (3 is not existing) // ++ THIRD std::cout << " - INSERT (0,3)" << std::endl; typeVectorVertex SimplexVector3; SimplexVector3.push_back(FOURTH_VERTEX_HANDLE); SimplexVector3.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector3.size() == 2 ); - st.insert_simplex_and_subfaces ( SimplexVector3 ); + BOOST_CHECK(SimplexVector3.size() == 2); + st.insert_simplex_and_subfaces(SimplexVector3); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); // Not incremented (all are existing) + BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing) // ++ FOURTH std::cout << " - INSERT (1,0) (already inserted)" << std::endl; typeVectorVertex SimplexVector4; SimplexVector4.push_back(SECOND_VERTEX_HANDLE); SimplexVector4.push_back(FIRST_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector4.size() == 2 ); - st.insert_simplex_and_subfaces ( SimplexVector4 ); + BOOST_CHECK(SimplexVector4.size() == 2); + st.insert_simplex_and_subfaces(SimplexVector4); - BOOST_CHECK( st.num_vertices() == (size_t)4 ); // Not incremented (all are existing) + BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented (all are existing) // ++ FIFTH std::cout << " - INSERT (3,4,5)" << std::endl; @@ -469,10 +477,10 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) SimplexVector5.push_back(FOURTH_VERTEX_HANDLE); SimplexVector5.push_back(FIFTH_VERTEX_HANDLE); SimplexVector5.push_back(SIXTH_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector5.size() == 3 ); - st.insert_simplex_and_subfaces ( SimplexVector5 ); + BOOST_CHECK(SimplexVector5.size() == 3); + st.insert_simplex_and_subfaces(SimplexVector5); - BOOST_CHECK( st.num_vertices() == (size_t)6 ); + BOOST_CHECK(st.num_vertices() == (size_t) 6); // ++ SIXTH std::cout << " - INSERT (0,1,6,7)" << std::endl; @@ -481,10 +489,10 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) SimplexVector6.push_back(SECOND_VERTEX_HANDLE); SimplexVector6.push_back(SEVENTH_VERTEX_HANDLE); SimplexVector6.push_back(EIGHTH_VERTEX_HANDLE); - BOOST_CHECK( SimplexVector6.size() == 4 ); - st.insert_simplex_and_subfaces ( SimplexVector6 ); + BOOST_CHECK(SimplexVector6.size() == 4); + st.insert_simplex_and_subfaces(SimplexVector6); - BOOST_CHECK( st.num_vertices() == (size_t)8 ); // +2 (6 and 7 are not existing - 0 and 1 are already existing) + BOOST_CHECK(st.num_vertices() == (size_t) 8); // +2 (6 and 7 are not existing - 0 and 1 are already existing) /* Inserted simplex: */ /* 1 6 */ @@ -507,13 +515,13 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) typeSimplex simplexPair4 = std::make_pair(SimplexVector4, DEFAULT_FILTRATION_VALUE); typeSimplex simplexPair5 = std::make_pair(SimplexVector5, DEFAULT_FILTRATION_VALUE); typeSimplex simplexPair6 = std::make_pair(SimplexVector6, DEFAULT_FILTRATION_VALUE); - test_simplex_tree_contains(st,simplexPair1,6); // (2,1,0) is in position 6 - test_simplex_tree_contains(st,simplexPair2,7); // (3) is in position 7 - test_simplex_tree_contains(st,simplexPair3,8); // (3,0) is in position 8 - test_simplex_tree_contains(st,simplexPair4,2); // (1,0) is in position 2 - test_simplex_tree_contains(st,simplexPair5,14); // (3,4,5) is in position 14 - test_simplex_tree_contains(st,simplexPair6,26); // (7,6,1,0) is in position 26 - + test_simplex_tree_contains(st, simplexPair1, 6); // (2,1,0) is in position 6 + test_simplex_tree_contains(st, simplexPair2, 7); // (3) is in position 7 + test_simplex_tree_contains(st, simplexPair3, 8); // (3,0) is in position 8 + test_simplex_tree_contains(st, simplexPair4, 2); // (1,0) is in position 2 + test_simplex_tree_contains(st, simplexPair5, 14); // (3,4,5) is in position 14 + test_simplex_tree_contains(st, simplexPair6, 26); // (7,6,1,0) is in position 26 + // ------------------------------------------------------------------------------------------------------------------ // Find in the simplex_tree // ------------------------------------------------------------------------------------------------------------------ @@ -548,7 +556,7 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) std::cout << "***- NO IT ISN'T\n"; // Check it is found BOOST_CHECK(simplexFound != st.null_simplex()); - + typeVectorVertex otherSimplexVector; otherSimplexVector.push_back(UNKNOWN_VERTEX_HANDLE); otherSimplexVector.push_back(SECOND_VERTEX_HANDLE); @@ -573,17 +581,17 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) std::cout << "***- NO IT ISN'T\n"; // Check it is found BOOST_CHECK(simplexFound != st.null_simplex()); - + + + // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; - for( auto f_simplex : st.filtration_simplex_range() ) - { + for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for( auto vertex : st.simplex_vertex_range(f_simplex) ) - { - std::cout << (int)vertex << " "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; } std::cout << std::endl; } @@ -624,4 +632,5 @@ BOOST_AUTO_TEST_CASE( NSimplexAndSubfaces_tree_insertion ) st_copy_4.edge_contraction(1, 6); std::cout << "Printing a copy of st, with the edge (1, 6) contracted, 6 being contracted in 1" << std::endl; st_copy_4.print_tree(); + } -- cgit v1.2.3