summaryrefslogtreecommitdiff
path: root/src/Skeleton_blocker/test
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-13 15:34:28 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-10-13 15:34:28 +0000
commitff6ad8b959f6c20380f3d68ebb1bbbf1224adcfd (patch)
treedf1906b0186dc9d9fa6f1f4b676ada8d0d921d23 /src/Skeleton_blocker/test
parentb677f53a744aec6b3edefbd297bba215eb70a4e0 (diff)
Manual merge of skb_simplex_insertion after last trunk big modifications on Skbl
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/skb_simplex_insertion_merge@855 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d7f7721e2963de439a28040196423d4c0df07d3f
Diffstat (limited to 'src/Skeleton_blocker/test')
-rw-r--r--src/Skeleton_blocker/test/TestGeometricComplex.cpp154
-rw-r--r--src/Skeleton_blocker/test/TestSimplifiable.cpp620
-rw-r--r--src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp1632
3 files changed, 1226 insertions, 1180 deletions
diff --git a/src/Skeleton_blocker/test/TestGeometricComplex.cpp b/src/Skeleton_blocker/test/TestGeometricComplex.cpp
index bd7af89b..084e2b6b 100644
--- a/src/Skeleton_blocker/test/TestGeometricComplex.cpp
+++ b/src/Skeleton_blocker/test/TestGeometricComplex.cpp
@@ -1,24 +1,24 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -33,8 +33,8 @@ using namespace std;
using namespace Gudhi;
using namespace skbl;
-struct Geometry_trait{
- typedef std::vector<double> Point;
+struct Geometry_trait {
+ typedef std::vector<double> Point;
};
typedef Geometry_trait::Point Point;
@@ -42,79 +42,77 @@ typedef Skeleton_blocker_simple_geometric_traits<Geometry_trait> Complex_geometr
typedef Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex;
typedef Complex::Vertex_handle Vertex_handle;
+bool test_constructor1() {
+ Complex complex;
+ Skeleton_blocker_off_reader<Complex> off_reader("test2.off", complex);
+ if (!off_reader.is_valid()) {
+ std::cerr << "Unable to read file" << std::endl;
+ return false;
+ }
-bool test_constructor1(){
- Complex complex;
- Skeleton_blocker_off_reader<Complex> off_reader("test2.off",complex);
- if(!off_reader.is_valid()){
- std::cerr << "Unable to read file"<<std::endl;
- return false;
- }
+ std::cout << "complex has " <<
+ complex.num_vertices() << " vertices, " <<
+ complex.num_blockers() << " blockers, " <<
+ complex.num_edges() << " edges and" <<
+ complex.num_triangles() << " triangles.";
- std::cout << "complex has "<<
- complex.num_vertices()<<" vertices, "<<
- complex.num_blockers()<<" blockers, "<<
- complex.num_edges()<<" edges and" <<
- complex.num_triangles()<<" triangles.";
+ if (complex.num_vertices() != 7 || complex.num_edges() != 12 || complex.num_triangles() != 6)
+ return false;
- if(complex.num_vertices()!=7 || complex.num_edges()!=12 || complex.num_triangles() !=6)
- return false;
+ Skeleton_blocker_off_writer<Complex> off_writer("tmp.off", complex);
+ Complex same;
+ Skeleton_blocker_off_reader<Complex> off_reader2("tmp.off", same);
- Skeleton_blocker_off_writer<Complex> off_writer("tmp.off",complex);
- Complex same;
- Skeleton_blocker_off_reader<Complex> off_reader2("tmp.off",same);
+ std::cout << "\ncomplex:" << complex.to_string() << endl;
+ std::cout << "\nsame:" << same.to_string() << endl;
- std::cout<<"\ncomplex:"<<complex.to_string()<<endl;
- std::cout<<"\nsame:"<<same.to_string()<<endl;
-
- return (complex==same);
+ return (complex == same);
}
-bool test_constructor2(){
- Complex complex;
- Skeleton_blocker_off_reader<Complex> off_reader("test2.off",complex);
- if(!off_reader.is_valid()){
- std::cerr << "Unable to read file"<<std::endl;
- return false;
- }
- std::cout << "complex has "<<
- complex.num_vertices()<<" vertices, "<<
- complex.num_blockers()<<" blockers, "<<
- complex.num_edges()<<" edges and" <<
- complex.num_triangles()<<" triangles.";
+bool test_constructor2() {
+ Complex complex;
+ Skeleton_blocker_off_reader<Complex> off_reader("test2.off", complex);
+ if (!off_reader.is_valid()) {
+ std::cerr << "Unable to read file" << std::endl;
+ return false;
+ }
+ std::cout << "complex has " <<
+ complex.num_vertices() << " vertices, " <<
+ complex.num_blockers() << " blockers, " <<
+ complex.num_edges() << " edges and" <<
+ complex.num_triangles() << " triangles.";
- if(complex.num_vertices()!=7 || complex.num_edges()!=12 || complex.num_triangles() !=6)
- return false;
+ if (complex.num_vertices() != 7 || complex.num_edges() != 12 || complex.num_triangles() != 6)
+ return false;
- auto link_0 = complex.abstract_link(Vertex_handle(0));
+ auto link_0 = complex.abstract_link(Vertex_handle(0));
- std::cout<<"\n link(0):"<<link_0.to_string()<<endl;
+ std::cout << "\n link(0):" << link_0.to_string() << endl;
- auto link_geometric_0 = complex.link(Vertex_handle(0));
+ auto link_geometric_0 = complex.link(Vertex_handle(0));
- auto print_point = [&](Vertex_handle v){for(auto x : link_geometric_0.point(v)) std::cout <<x<<" "; std::cout<<std::endl;};
+ auto print_point = [&](Vertex_handle v) {
+ for (auto x : link_geometric_0.point(v)) std::cout << x << " ";
+ std::cout << std::endl;
+ };
- std::for_each(link_geometric_0.vertex_range().begin(),link_geometric_0.vertex_range().end(),print_point);
+ std::for_each(link_geometric_0.vertex_range().begin(), link_geometric_0.vertex_range().end(), print_point);
-// for(auto v : link_geometric_0.vertex_range())
-// std::cout<<"point("<<v<<"):"<<link_geometric_0.point(v)<<std::endl;
+ // for(auto v : link_geometric_0.vertex_range())
+ // std::cout<<"point("<<v<<"):"<<link_geometric_0.point(v)<<std::endl;
- return link_0.num_vertices()==2;
+ return link_0.num_vertices() == 2;
}
+int main(int argc, char *argv[]) {
+ Tests tests_geometric_complex;
+ tests_geometric_complex.add("Test constructor 1", test_constructor1);
+ tests_geometric_complex.add("Test constructor 2", test_constructor2);
-
-
-int main (int argc, char *argv[])
-{
- Tests tests_geometric_complex;
- tests_geometric_complex.add("Test constructor 1",test_constructor1);
- tests_geometric_complex.add("Test constructor 2",test_constructor2);
-
- if(tests_geometric_complex.run())
- return EXIT_SUCCESS;
- else
- return EXIT_FAILURE;
+ if (tests_geometric_complex.run())
+ return EXIT_SUCCESS;
+ else
+ return EXIT_FAILURE;
}
diff --git a/src/Skeleton_blocker/test/TestSimplifiable.cpp b/src/Skeleton_blocker/test/TestSimplifiable.cpp
index 09176934..76d5ba89 100644
--- a/src/Skeleton_blocker/test/TestSimplifiable.cpp
+++ b/src/Skeleton_blocker/test/TestSimplifiable.cpp
@@ -1,24 +1,24 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <stdio.h>
@@ -41,316 +41,382 @@ template<typename ComplexType> class Skeleton_blocker_sub_complex;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Root_vertex_handle Root_vertex_handle;
-typedef Skeleton_blocker_simplex<Vertex_handle> Simplex_handle;
+typedef Skeleton_blocker_simplex<Vertex_handle> Simplex;
// true iff v \in complex
-bool assert_vertex(Complex &complex,Vertex_handle v){
- Simplex_handle simplex(v);
- bool test = complex.contains(simplex);
- assert(test);
- return test;
+
+bool assert_vertex(Complex &complex, Vertex_handle v) {
+ Simplex simplex(v);
+ bool test = complex.contains(simplex);
+ assert(test);
+ return test;
}
// true iff the blocker (a,b,c) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return complex.contains_blocker(Simplex_handle(*complex.get_address(a),*complex.get_address(b),*complex.get_address(c)));
- //return complex.contains_blocker((a),(b),(c));
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+
+ return complex.contains_blocker(Simplex(*complex.get_address(a), *complex.get_address(b), *complex.get_address(c)));
+ //return complex.contains_blocker((a),(b),(c));
}
-void build_complete(int n,Complex& complex){
- complex.clear();
- for(int i=0;i<n;i++)
- complex.add_vertex();
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
+void build_complete(int n, Complex& complex) {
+ complex.clear();
+ for (int i = 0; i < n; i++)
+ complex.add_vertex();
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
}
-bool test_contraction1(){
- enum { a, b, x, y, z, n };
- Complex complex(n);
- build_complete(n,complex);
- complex.remove_edge(static_cast<Vertex_handle>(b), static_cast<Vertex_handle>(z));
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(a), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y)));
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(b), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y)));
-
- // Print result
- cerr << "complex before complex"<< complex.to_string()<<endl;
-
- cerr <<endl<<endl;
- complex.contract_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
- // Print result
- cerr << "ContractEdge(0,1)\n";
- PRINT(complex.to_string());
-
- // verification
- for (int i=0;i<5;i++)
- if (i!=1) assert_vertex(complex, static_cast<Vertex_handle>(i));
- bool test1 = !complex.contains_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
- bool test2 = assert_blocker(complex,Root_vertex_handle(a),Root_vertex_handle(x),Root_vertex_handle(y));
- bool test3 = complex.num_edges()==6;
- bool test4 = complex.num_blockers()==1;
- Simplex_handle sigma;
- sigma.add_vertex(static_cast<Vertex_handle>(a));
- sigma.add_vertex(static_cast<Vertex_handle>(x));
- sigma.add_vertex(static_cast<Vertex_handle>(y));
- sigma.add_vertex(static_cast<Vertex_handle>(z));
- bool test5 = !(complex.contains(sigma));
- return test1&&test2&&test3&&test4&&test5;
+bool test_contraction1() {
+
+ enum {
+ a, b, x, y, z, n
+ };
+ Complex complex(n);
+ build_complete(n, complex);
+ complex.remove_edge(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (z));
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y)));
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y)));
+
+ // Print result
+ cerr << "complex before complex" << complex.to_string() << endl;
+
+ cerr << endl << endl;
+ complex.contract_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
+ // Print result
+ cerr << "ContractEdge(0,1)\n";
+ PRINT(complex.to_string());
+
+ // verification
+ for (int i = 0; i < 5; i++)
+ if (i != 1) assert_vertex(complex, static_cast<Vertex_handle> (i));
+ bool test1 = !complex.contains_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
+ bool test2 = assert_blocker(complex, Root_vertex_handle(a), Root_vertex_handle(x), Root_vertex_handle(y));
+ bool test3 = complex.num_edges() == 6;
+ bool test4 = complex.num_blockers() == 1;
+ Simplex sigma;
+ sigma.add_vertex(static_cast<Vertex_handle> (a));
+ sigma.add_vertex(static_cast<Vertex_handle> (x));
+ sigma.add_vertex(static_cast<Vertex_handle> (y));
+ sigma.add_vertex(static_cast<Vertex_handle> (z));
+ bool test5 = !(complex.contains(sigma));
+ return test1 && test2 && test3 && test4&&test5;
}
+bool test_contraction2() {
-bool test_contraction2(){
- enum { a, b, x, y, z, n };
- Complex complex(n);
- build_complete(n,complex);
- complex.remove_edge(static_cast<Vertex_handle>(b),static_cast<Vertex_handle>(x));
- Simplex_handle blocker;
- blocker.add_vertex(static_cast<Vertex_handle>(a));
- blocker.add_vertex(static_cast<Vertex_handle>(y));
- blocker.add_vertex(static_cast<Vertex_handle>(z));
+ enum {
+ a, b, x, y, z, n
+ };
+ Complex complex(n);
+ build_complete(n, complex);
+ complex.remove_edge(static_cast<Vertex_handle> (b), static_cast<Vertex_handle> (x));
+ Simplex blocker;
+ blocker.add_vertex(static_cast<Vertex_handle> (a));
+ blocker.add_vertex(static_cast<Vertex_handle> (y));
+ blocker.add_vertex(static_cast<Vertex_handle> (z));
- complex.add_blocker(blocker);
+ complex.add_blocker(blocker);
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- complex.contract_edge(static_cast<Vertex_handle>(a),static_cast<Vertex_handle>(b));
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ complex.contract_edge(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (b));
- cerr << "complex.ContractEdge(a,b)"<< complex.to_string();
+ cerr << "complex.ContractEdge(a,b)" << complex.to_string();
- cerr <<endl<<endl;
+ cerr << endl << endl;
- // there should be one blocker (a,c,d,e) in the complex
- bool test ;
- test = complex.contains_blocker(Simplex_handle(static_cast<Vertex_handle>(a), static_cast<Vertex_handle>(x),
- static_cast<Vertex_handle>(y),static_cast<Vertex_handle>(z)));
- test = test && complex.num_blockers()==1;
- return test;
+ // there should be one blocker (a,c,d,e) in the complex
+ bool test;
+ test = complex.contains_blocker(Simplex(static_cast<Vertex_handle> (a), static_cast<Vertex_handle> (x),
+ static_cast<Vertex_handle> (y), static_cast<Vertex_handle> (z)));
+ test = test && complex.num_blockers() == 1;
+ return test;
}
-bool test_link_condition1(){
+bool test_link_condition1() {
- Complex complex(0);
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(static_cast<Vertex_handle>(0), static_cast<Vertex_handle>(1), static_cast<Vertex_handle>(2)));
+ Complex complex(0);
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(static_cast<Vertex_handle> (0), static_cast<Vertex_handle> (1), static_cast<Vertex_handle> (2)));
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
- bool weak_link_condition = complex.link_condition(Vertex_handle(1),Vertex_handle(2),true);
+ bool weak_link_condition = complex.link_condition(Vertex_handle(1), Vertex_handle(2), true);
- bool strong_link_condition = complex.link_condition(Vertex_handle(1),Vertex_handle(2),false);
+ bool strong_link_condition = complex.link_condition(Vertex_handle(1), Vertex_handle(2), false);
- return weak_link_condition && !strong_link_condition;
+ return weak_link_condition && !strong_link_condition;
}
-
-bool test_collapse0(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(static_cast<Vertex_handle>(2), static_cast<Vertex_handle>(4));
- complex.add_edge(static_cast<Vertex_handle>(3), static_cast<Vertex_handle>(4));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle simplex_123(static_cast<Vertex_handle>(1), static_cast<Vertex_handle>(2), static_cast<Vertex_handle>(3));
- complex.remove_star(simplex_123);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool blocker123_here = complex.contains_blocker(simplex_123);
- cerr <<"----> Ocomplex \n";
- return blocker123_here;
+bool test_collapse0() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(static_cast<Vertex_handle> (2), static_cast<Vertex_handle> (4));
+ complex.add_edge_without_blockers(static_cast<Vertex_handle> (3), static_cast<Vertex_handle> (4));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex simplex_123(static_cast<Vertex_handle> (1), static_cast<Vertex_handle> (2), static_cast<Vertex_handle> (3));
+ complex.remove_star(simplex_123);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool blocker123_here = complex.contains_blocker(simplex_123);
+ cerr << "----> Ocomplex \n";
+ return blocker123_here;
}
-
-bool test_collapse1(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle simplex_123(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- complex.remove_star(simplex_123);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool res = complex.contains_blocker(simplex_123);
- res = res && complex.num_blockers()==1;
- cerr <<"----> Ocomplex \n";
- return res;
+bool test_collapse1() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex simplex_123(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ complex.remove_star(simplex_123);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool res = complex.contains_blocker(simplex_123);
+ res = res && complex.num_blockers() == 1;
+ cerr << "----> Ocomplex \n";
+ return res;
}
-bool test_collapse2(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(1),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- // Print result
- cerr << "initial complex :\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- Simplex_handle sigma(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- complex.remove_star(sigma);
- cerr << "complex.remove_star(1,2,3):\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- // verification
- bool blocker_removed = !complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- bool blocker123_here = complex.contains_blocker(sigma);
- return blocker_removed && blocker123_here;
+bool test_collapse2() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ // Print result
+ cerr << "initial complex :\n" << complex.to_string();
+ cerr << endl << endl;
+
+ Simplex sigma(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ complex.remove_star(sigma);
+ cerr << "complex.remove_star(1,2,3):\n" << complex.to_string();
+ cerr << endl << endl;
+
+ // verification
+ bool blocker_removed = !complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ bool blocker123_here = complex.contains_blocker(sigma);
+ return blocker_removed && blocker123_here;
}
-bool test_collapse3(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(1),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- complex.remove_star(static_cast<Vertex_handle>(2));
- cerr << "complex after remove star of 2:\n"<< complex.to_string();
-
- bool blocker134_here = complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(3),Vertex_handle(4)));
- bool blocker1234_here = complex.contains_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3),Vertex_handle(4)));
- return blocker134_here && !blocker1234_here;
+bool test_collapse3() {
+ Complex complex(5);
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+
+ complex.remove_star(static_cast<Vertex_handle> (2));
+ cerr << "complex after remove star of 2:\n" << complex.to_string();
+
+ bool blocker134_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(3), Vertex_handle(4)));
+ bool blocker1234_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4)));
+ return blocker134_here && !blocker1234_here;
}
-bool test_add_simplex(){
- Complex complex(5);
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
-
- complex.add_simplex(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
- cerr << "complex after add_simplex:\n"<< complex.to_string();
-
- return complex.num_blockers()==0;
+bool test_add_simplex() {
+ Complex complex(4);
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)));
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+
+ complex.add_simplex(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)));
+ cerr << "complex after add_simplex:\n" << complex.to_string();
+ return complex.num_blockers() == 1
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
}
-bool test_add_simplex2(){
- Complex complex;
- build_complete(4,complex);
- // Print result
- cerr << "initial complex:\n"<< complex.to_string();
- cerr <<endl<<endl;
+bool test_add_simplex2() {
+ Complex complex;
+ build_complete(4, complex);
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
- Complex copy(complex.num_vertices());
+ Complex copy(complex.num_vertices());
- std::vector<Simplex_handle> simplices(complex.simplex_range().begin(),complex.simplex_range().end());
- sort(simplices.begin(),simplices.end(),[&](const Simplex_handle& s1,const Simplex_handle& s2){
- return s1.dimension()<s2.dimension();
- });
- for(const auto & simplex : simplices){
- if(!copy.contains(simplex) && simplex.dimension()==1)
- copy.add_edge(simplex.first_vertex(),simplex.last_vertex());
- if(!copy.contains(simplex) && simplex.dimension()>1)
- copy.add_simplex(simplex);
- }
+ std::vector<Simplex> simplices(complex.complex_simplex_range().begin(), complex.complex_simplex_range().end());
+ sort(simplices.begin(), simplices.end(), [&](const Simplex& s1, const Simplex & s2) {
+ return s1.dimension() < s2.dimension();
+ });
+ for (const auto & simplex : simplices) {
+ if (!copy.contains(simplex) && simplex.dimension() == 1)
+ copy.add_edge_without_blockers(simplex.first_vertex(), simplex.last_vertex());
+ if (!copy.contains(simplex) && simplex.dimension() > 1)
+ copy.add_simplex(simplex);
+ }
- cerr << "complex after add_simplex:\n"<< copy.to_string();
+ cerr << "complex after add_simplex:\n" << copy.to_string();
- return complex.num_blockers()==copy.num_blockers() &&
- complex.num_edges()==copy.num_edges() &&
- complex.num_vertices()==copy.num_vertices();
+ return complex.num_blockers() == copy.num_blockers() &&
+ complex.num_edges() == copy.num_edges() &&
+ complex.num_vertices() == copy.num_vertices();
}
+bool test_add_simplex3() {
+ Complex complex(5);
+ build_complete(5, complex);
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(4));
+ Simplex sigma(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
+ complex.add_blocker(sigma);
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+ complex.add_simplex(sigma);
+ //should create two blockers 0123 and 0124
+ cerr << "complex after adding simplex 012:\n" << complex.to_string();
+ return complex.num_blockers() == 2
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)))
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(4)));
+}
-
-bool test_remove_popable_blockers(){
- Complex complex;
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- Simplex_handle sigma1=Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- Simplex_handle sigma2=Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(sigma1);
- complex.add_blocker(sigma2);
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "complex.RemovePopableBlockers();"<<endl;
- complex.remove_popable_blockers();
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
-
- bool test1 = (complex.num_blockers()==1);
-
-
- // test 2
- complex.clear();
- build_complete(4,complex);
- complex.add_vertex();
- complex.add_vertex();
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(2),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(5));
- complex.add_edge(Vertex_handle(4),Vertex_handle(5));
- sigma1=Simplex_handle(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- sigma2=Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(sigma1);
- complex.add_blocker(sigma2);
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl; cerr << "complex.RemovePopableBlockers();"<<endl;
- complex.remove_popable_blockers();
- cerr << "complex complex"<< complex.to_string();
-
- cerr <<endl<<endl;
- bool test2 = (complex.num_blockers()==0);
- return test1&&test2;
+bool test_add_simplex4() {
+ int n = 6;
+ Complex complex(n);
+
+ // add all simplex 0..n without i
+ for (int i = 0; i < n; i++) {
+ Simplex s;
+ for (int k = 0; k < n; k++)
+ s.add_vertex(Vertex_handle(k));
+ s.remove_vertex(Vertex_handle(i));
+ complex.add_simplex(s, true);
+
+ //at step i there is only blocker 0..i
+ if (i < 2 && complex.num_blockers() > 0)
+ return false;
+ if (i >= 2 && complex.num_blockers() != 1) {
+ Simplex b;
+ for (int k = 0; k < i; k++)
+ b.add_vertex(Vertex_handle(i));
+ if (!complex.contains_blocker(b))
+ return false;
+ }
+ TESTVALUE(complex.blockers_to_string());
+ }
+ Simplex s;
+ for (int k = 0; k < n; k++)
+ s.add_vertex(Vertex_handle(k));
+ return complex.num_blockers() == 1 && complex.contains_blocker(s);
}
+bool test_add_edge() {
+ Complex complex(4);
+ for (unsigned i = 0u; i < 4; i++)
+ complex.add_edge(Vertex_handle(i), Vertex_handle((i + 1) % 4));
+
+ // Print result
+ cerr << "initial complex:\n" << complex.to_string();
+ cerr << endl << endl;
+ complex.add_edge(Vertex_handle(1), Vertex_handle(3));
+ //should create two blockers 013 and 012
+ cerr << "complex after adding edge 13:\n" << complex.to_string();
+ return complex.num_blockers() == 2
+ && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3)))
+ && complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+}
+bool test_remove_popable_blockers() {
+ Complex complex;
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ Simplex sigma1 = Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ Simplex sigma2 = Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(sigma1);
+ complex.add_blocker(sigma2);
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "complex.RemovePopableBlockers();" << endl;
+ complex.remove_popable_blockers();
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+
+ bool test1 = (complex.num_blockers() == 1);
+
+
+ // test 2
+ complex.clear();
+ build_complete(4, complex);
+ complex.add_vertex();
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(5));
+ sigma1 = Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ sigma2 = Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(sigma1);
+ complex.add_blocker(sigma2);
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "complex.RemovePopableBlockers();" << endl;
+ complex.remove_popable_blockers();
+ cerr << "complex complex" << complex.to_string();
+
+ cerr << endl << endl;
+ bool test2 = (complex.num_blockers() == 0);
+ return test1&&test2;
+}
-int main (int argc, char *argv[])
-{
- Tests tests_simplifiable_complex;
- tests_simplifiable_complex.add("Test contraction 1",test_contraction1);
- tests_simplifiable_complex.add("Test contraction 2",test_contraction2);
- tests_simplifiable_complex.add("Test Link condition 1",test_link_condition1);
- tests_simplifiable_complex.add("Test remove popable blockers",test_remove_popable_blockers);
+int main(int argc, char *argv[]) {
+ Tests tests_simplifiable_complex;
+ tests_simplifiable_complex.add("Test contraction 1", test_contraction1);
+ tests_simplifiable_complex.add("Test contraction 2", test_contraction2);
+ tests_simplifiable_complex.add("Test Link condition 1", test_link_condition1);
+ tests_simplifiable_complex.add("Test remove popable blockers", test_remove_popable_blockers);
- tests_simplifiable_complex.add("Test collapse 0",test_collapse0);
- tests_simplifiable_complex.add("Test collapse 1",test_collapse1);
- tests_simplifiable_complex.add("Test collapse 2",test_collapse2);
- tests_simplifiable_complex.add("Test collapse 3",test_collapse3);
+ tests_simplifiable_complex.add("Test collapse 0", test_collapse0);
+ tests_simplifiable_complex.add("Test collapse 1", test_collapse1);
+ tests_simplifiable_complex.add("Test collapse 2", test_collapse2);
+ tests_simplifiable_complex.add("Test collapse 3", test_collapse3);
- tests_simplifiable_complex.add("Test add simplex",test_add_simplex);
- tests_simplifiable_complex.add("Test add simplex2",test_add_simplex2);
+ tests_simplifiable_complex.add("Test add edge",test_add_edge);
+ tests_simplifiable_complex.add("Test add simplex", test_add_simplex);
+ tests_simplifiable_complex.add("Test add simplex2", test_add_simplex2);
+ tests_simplifiable_complex.add("Test add simplex3",test_add_simplex3);
+ tests_simplifiable_complex.add("Test add simplex4",test_add_simplex4);
- tests_simplifiable_complex.run();
+ tests_simplifiable_complex.run();
- if(tests_simplifiable_complex.run())
- return EXIT_SUCCESS;
- else
- return EXIT_FAILURE;
+ if (tests_simplifiable_complex.run())
+ return EXIT_SUCCESS;
+ else
+ return EXIT_FAILURE;
}
diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
index 319e3c43..418638e8 100644
--- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
+++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp
@@ -42,911 +42,893 @@ using namespace skbl;
typedef Skeleton_blocker_complex<Skeleton_blocker_simple_traits> Complex;
typedef Complex::Vertex_handle Vertex_handle;
typedef Complex::Root_vertex_handle Root_vertex_handle;
-typedef Complex::Simplex_handle Simplex_handle;
+typedef Complex::Simplex Simplex;
typedef Complex::Root_simplex_handle Root_simplex_handle;
-typedef Simplex_handle::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
+typedef Simplex::Simplex_vertex_const_iterator Simplex_vertex_const_iterator;
typedef Complex::Edge_handle Edge_handle;
// true if v in complex
-bool assert_vertex(Complex &complex,Vertex_handle v){
- //assert(complex.contains(v));
- return complex.contains(static_cast<Simplex_handle>(v));
-}
-
-bool assert_simplex(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return true;
- // AddressSimplex simplex((a),(b),(c));
- // return complex.contains(&simplex);
-}
-// true iff the blocker (a,b,c) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c){
- return true;
- //return complex.contains_blocker((a),(b),(c));
+bool assert_vertex(Complex &complex, Vertex_handle v) {
+ //assert(complex.contains(v));
+ return complex.contains(static_cast<Simplex> (v));
}
-// true iff the blocker (a,b,c,d) is in complex
-bool assert_blocker(Complex &complex,Root_vertex_handle a,Root_vertex_handle b,Root_vertex_handle c,Root_vertex_handle d){
- return true;
- //Simplex blocker (a,b,c,d);
- //return complex.contains_blocker(&blocker);
-}
-
-
-
-void build_complete(int n,Complex& complex){
- complex.clear();
- for(int i=0;i<n;i++)
- complex.add_vertex();
-
- // for(int i=n-1;i>=0;i--)
- // for(int j=i-1;j>=0;j--)
- // complex.add_edge(Vertex_handle(i),Vertex_handle(j));
-
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
-}
-
-
-bool test_simplex(){
- // PRINT("test simplex");
- Simplex_handle simplex(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3));
- for (auto i = simplex.begin() ; i != simplex.end() ; ++i){
- PRINT(*i);
- auto j = i;
- for (++j ;
- j != simplex.end() ;
- ++j){
- PRINT(*j);
- }
- }
- return simplex.dimension()==3;
-}
-
-
-bool test_iterator_vertices1(){
- int n = 10;
- Complex complex(10);
- cerr << "complex.num_vertices():"<<complex.num_vertices()<<endl;
- int num_vertex_seen = 0;
- for(auto vi :complex.vertex_range()){
- cerr << "vertex:"<<vi<<endl;
- ++num_vertex_seen;
- }
- return num_vertex_seen == n;
-}
-
-bool test_iterator_vertices2(){
- int n = 10;
- Complex complex(10);
- build_complete(10,complex);
- cerr << "complex.num_vertices():"<<complex.num_vertices()<<endl;
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_vertex_seen = 0;
- for(auto vi :complex.vertex_range(Vertex_handle(2))){
- cerr << "vertex:"<<vi<<endl;
- ++num_vertex_seen;
- }
- std::cerr<<"num_vertex_seen:"<<num_vertex_seen<<std::endl;
- return num_vertex_seen == (n-1);
-}
-
-
-
-bool test_iterator_edge(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_edges_seen = 0;
- for(auto edge : complex.edge_range()){
- cerr << "edge :"<<complex[edge]<<endl;
- ++num_edges_seen;
- }
-
- return num_edges_seen == n*(n-1)/2-2;
-}
-
-bool test_iterator_edge2(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_neigbors_seen = 0;
- for(auto neighbor : complex.vertex_range(Vertex_handle(2))){
- cerr << "neighbor"<<neighbor<<endl;
- ++num_neigbors_seen;
- }
- return num_neigbors_seen==8;
-}
-
-
-
-bool test_iterator_edge3(){
- const int n = 10;
- Complex complex(n);
- for(int i=0;i<n;i++)
- for(int j=0;j<i;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- complex.remove_edge(Vertex_handle(2),Vertex_handle(3));
- complex.remove_edge(Vertex_handle(3),Vertex_handle(5));
- cerr << "complex.num_edges():"<<complex.num_edges()<<endl;
- int num_neigbors_seen = 0;
- for(auto edge : complex.edge_range(Vertex_handle(2))){
- std::cerr << edge<< std::endl;
- ++num_neigbors_seen;
- }
- return num_neigbors_seen==8;
-}
-
-
-
-bool test_iterator_triangles(){
- const int n = 7;
- Complex complex(n);
- //create a "ring" around '0'
- for(int i=1;i<n;i++)
- complex.add_edge(Vertex_handle(0),Vertex_handle(i));
- for(int i=1;i<n-1;i++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(i+1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(6));
-
- PRINT(complex.to_string());
-
- int num_triangles_seen=0;
- //for (auto t : complex.triangle_range(5)){
- TEST("triangles around 5 (should be 2 of them):");
- for (auto t : complex.triangle_range(Vertex_handle(5))){
- PRINT(t);
- ++num_triangles_seen;
- }
- bool test = (num_triangles_seen==2);
-
- num_triangles_seen=0;
- TEST("triangles around 0 (should be 6 of them):");
- for (auto t : complex.triangle_range(Vertex_handle(0))){
- PRINT(t);
- ++num_triangles_seen;
- }
- test = test&&(num_triangles_seen==6);
-
- // we now add another triangle
- complex.add_vertex();
- complex.add_edge(Vertex_handle(4),Vertex_handle(7));
- complex.add_edge(Vertex_handle(3),Vertex_handle(7));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(6)));
- num_triangles_seen=0;
-
- TEST("triangles (should be 6 of them):");
- num_triangles_seen=0;
- for (auto t : complex.triangle_range()){
- PRINT(t);
- ++num_triangles_seen;
- }
- test = test&&(num_triangles_seen==6);
- PRINT(num_triangles_seen);
-
- return test;
+bool assert_simplex(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+ return true;
+ // AddressSimplex simplex((a),(b),(c));
+ // return complex.contains(&simplex);
}
+// true iff the blocker (a,b,c) is in complex
-//#include "combinatorics/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h"
-
-bool test_iterator_simplices(){
- Complex complex(6);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(2));
- complex.add_edge(Vertex_handle(2),Vertex_handle(0));
- complex.add_edge(Vertex_handle(1),Vertex_handle(3));
- complex.add_edge(Vertex_handle(2),Vertex_handle(3));
- complex.add_edge(Vertex_handle(2),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(5));
- complex.add_edge(Vertex_handle(2),Vertex_handle(4));
- complex.add_edge(Vertex_handle(4),Vertex_handle(5));
- complex.add_edge(Vertex_handle(3),Vertex_handle(4));
-
- complex.add_blocker(Simplex_handle(Vertex_handle(2),Vertex_handle(3),Vertex_handle(4),Vertex_handle(5)));
-
- bool correct_number_simplices = true;
-
- std::map<Vertex_handle,unsigned> expected_num_simplices;
-
- expected_num_simplices[Vertex_handle(0)] = 4;
- expected_num_simplices[Vertex_handle(1)] = 6;
- expected_num_simplices[Vertex_handle(2)] = 11;
- expected_num_simplices[Vertex_handle(3)] = 9;
- expected_num_simplices[Vertex_handle(4)] = 7;
- expected_num_simplices[Vertex_handle(5)] = 7;
-
- for(auto pair : expected_num_simplices){
- unsigned num_simplices_around = 0;
- for(const auto& simplex : complex.simplex_range(pair.first)){
- simplex.dimension();
- DBGVALUE(simplex);
- ++num_simplices_around;
- }
-
- correct_number_simplices = correct_number_simplices && (num_simplices_around == pair.second);
-
- DBGMSG("current vertex:",pair.first);
- DBGMSG("expected_num_simplices:",pair.second);
- DBGMSG("found:",num_simplices_around);
- }
- return correct_number_simplices;
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c) {
+ return true;
+ //return complex.contains_blocker((a),(b),(c));
}
+// true iff the blocker (a,b,c,d) is in complex
-
-bool test_iterator_simplices2(){
- Complex complex(2);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
-
- for(const auto& s:complex.triangle_range()){
- s.dimension();
- return false; // there are no triangles
- }
-
- unsigned num_simplices = 0 ;
-
-
- DBGVALUE(complex.to_string());
-
- for(const auto& simplex : complex.simplex_range(Vertex_handle(0))){
- simplex.dimension();
- DBGVALUE(simplex);
- }
-
-
- for(const auto& simplex : complex.simplex_range()){
- DBGVALUE(simplex);
- simplex.dimension();
- ++num_simplices;
- }
- bool correct_number_simplices = (num_simplices == 3);
- return correct_number_simplices;
+bool assert_blocker(Complex &complex, Root_vertex_handle a, Root_vertex_handle b, Root_vertex_handle c, Root_vertex_handle d) {
+ return true;
+ //Simplex blocker (a,b,c,d);
+ //return complex.contains_blocker(&blocker);
+}
+
+void build_complete(int n, Complex& complex) {
+ complex.clear();
+ for (int i = 0; i < n; i++)
+ complex.add_vertex();
+
+ // for(int i=n-1;i>=0;i--)
+ // for(int j=i-1;j>=0;j--)
+ // complex.add_edge_without_blockers(Vertex_handle(i),Vertex_handle(j));
+
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+}
+
+bool test_simplex() {
+ // PRINT("test simplex");
+ Simplex simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3));
+ for (auto i = simplex.begin(); i != simplex.end(); ++i) {
+ PRINT(*i);
+ auto j = i;
+ for (++j;
+ j != simplex.end();
+ ++j) {
+ PRINT(*j);
+ }
+ }
+ return simplex.dimension() == 3;
+}
+
+bool test_iterator_vertices1() {
+ int n = 10;
+ Complex complex(10);
+ cerr << "complex.num_vertices():" << complex.num_vertices() << endl;
+ int num_vertex_seen = 0;
+ for (auto vi : complex.vertex_range()) {
+ cerr << "vertex:" << vi << endl;
+ ++num_vertex_seen;
+ }
+ return num_vertex_seen == n;
+}
+
+bool test_iterator_vertices2() {
+ int n = 10;
+ Complex complex(10);
+ build_complete(10, complex);
+ cerr << "complex.num_vertices():" << complex.num_vertices() << endl;
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_vertex_seen = 0;
+ for (auto vi : complex.vertex_range(Vertex_handle(2))) {
+ cerr << "vertex:" << vi << endl;
+ ++num_vertex_seen;
+ }
+ std::cerr << "num_vertex_seen:" << num_vertex_seen << std::endl;
+ return num_vertex_seen == (n - 1);
+}
+
+bool test_iterator_edge() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_edges_seen = 0;
+ for (auto edge : complex.edge_range()) {
+ cerr << "edge :" << complex[edge] << endl;
+ ++num_edges_seen;
+ }
+
+ return num_edges_seen == n * (n - 1) / 2 - 2;
+}
+
+bool test_iterator_edge2() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_neigbors_seen = 0;
+ for (auto neighbor : complex.vertex_range(Vertex_handle(2))) {
+ cerr << "neighbor" << neighbor << endl;
+ ++num_neigbors_seen;
+ }
+ return num_neigbors_seen == 8;
+}
+
+bool test_iterator_edge3() {
+ const int n = 10;
+ Complex complex(n);
+ for (int i = 0; i < n; i++)
+ for (int j = 0; j < i; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ complex.remove_edge(Vertex_handle(2), Vertex_handle(3));
+ complex.remove_edge(Vertex_handle(3), Vertex_handle(5));
+ cerr << "complex.num_edges():" << complex.num_edges() << endl;
+ int num_neigbors_seen = 0;
+ for (auto edge : complex.edge_range(Vertex_handle(2))) {
+ std::cerr << edge << std::endl;
+ ++num_neigbors_seen;
+ }
+ return num_neigbors_seen == 8;
+}
+
+bool test_iterator_triangles() {
+ const int n = 7;
+ Complex complex(n);
+ //create a "ring" around '0'
+ for (int i = 1; i < n; i++)
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(i));
+ for (int i = 1; i < n - 1; i++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(i + 1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(6));
+
+ PRINT(complex.to_string());
+
+ int num_triangles_seen = 0;
+ //for (auto t : complex.triangle_range(5)){
+ TEST("triangles around 5 (should be 2 of them):");
+ for (auto t : complex.triangle_range(Vertex_handle(5))) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ bool test = (num_triangles_seen == 2);
+
+ num_triangles_seen = 0;
+ TEST("triangles around 0 (should be 6 of them):");
+ for (auto t : complex.triangle_range(Vertex_handle(0))) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ test = test && (num_triangles_seen == 6);
+
+ // we now add another triangle
+ complex.add_vertex();
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(7));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(7));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(6)));
+ num_triangles_seen = 0;
+
+ TEST("triangles (should be 6 of them):");
+ num_triangles_seen = 0;
+ for (auto t : complex.triangle_range()) {
+ PRINT(t);
+ ++num_triangles_seen;
+ }
+ test = test && (num_triangles_seen == 6);
+ PRINT(num_triangles_seen);
+
+ return test;
}
-bool test_iterator_simplices3(){
- Complex complex(3);
- complex.add_edge(Vertex_handle(0),Vertex_handle(1));
- complex.add_edge(Vertex_handle(1),Vertex_handle(2));
- complex.add_edge(Vertex_handle(2),Vertex_handle(0));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
-
- unsigned num_simplices = 0 ;
-
- for(const auto& simplex : complex.simplex_range(Vertex_handle(0))){
- simplex.dimension();
- DBGVALUE(simplex);
- }
-
+//#include "combinatorics/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h"
- for(const auto& simplex : complex.simplex_range()){
- DBGVALUE(simplex);
- simplex.dimension();
- ++num_simplices;
- }
- bool correct_number_simplices = (num_simplices == 6);
- return correct_number_simplices;
+bool test_iterator_simplices() {
+ Complex complex(6);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(2));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(0));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(3));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(3));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(4));
+ complex.add_edge_without_blockers(Vertex_handle(4), Vertex_handle(5));
+ complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4));
+
+ complex.add_blocker(Simplex(Vertex_handle(2), Vertex_handle(3), Vertex_handle(4), Vertex_handle(5)));
+
+ bool correct_number_simplices = true;
+
+ std::map<Vertex_handle, unsigned> expected_num_simplices;
+
+ expected_num_simplices[Vertex_handle(0)] = 4;
+ expected_num_simplices[Vertex_handle(1)] = 6;
+ expected_num_simplices[Vertex_handle(2)] = 11;
+ expected_num_simplices[Vertex_handle(3)] = 9;
+ expected_num_simplices[Vertex_handle(4)] = 7;
+ expected_num_simplices[Vertex_handle(5)] = 7;
+
+ for (auto pair : expected_num_simplices) {
+ unsigned num_simplices_around = 0;
+ for (const auto& simplex : complex.star_simplex_range(pair.first)) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ ++num_simplices_around;
+ }
+
+ correct_number_simplices = correct_number_simplices && (num_simplices_around == pair.second);
+
+ DBGMSG("current vertex:", pair.first);
+ DBGMSG("expected_num_simplices:", pair.second);
+ DBGMSG("found:", num_simplices_around);
+ }
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices2() {
+ Complex complex(2);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+
+ for (const auto& s : complex.triangle_range()) {
+ s.dimension();
+ return false; // there are no triangles
+ }
+
+ unsigned num_simplices = 0;
+
+
+ DBGVALUE(complex.to_string());
+
+ for (const auto& simplex : complex.star_simplex_range(Vertex_handle(0))) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ }
+
+
+ for (const auto& simplex : complex.complex_simplex_range()) {
+ DBGVALUE(simplex);
+ simplex.dimension();
+ ++num_simplices;
+ }
+ bool correct_number_simplices = (num_simplices == 3);
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices3() {
+ Complex complex(3);
+ complex.add_edge_without_blockers(Vertex_handle(0), Vertex_handle(1));
+ complex.add_edge_without_blockers(Vertex_handle(1), Vertex_handle(2));
+ complex.add_edge_without_blockers(Vertex_handle(2), Vertex_handle(0));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+
+ unsigned num_simplices = 0;
+
+ for (const auto& simplex : complex.star_simplex_range(Vertex_handle(0))) {
+ simplex.dimension();
+ DBGVALUE(simplex);
+ }
+
+
+ for (const auto& simplex : complex.complex_simplex_range()) {
+ DBGVALUE(simplex);
+ simplex.dimension();
+ ++num_simplices;
+ }
+ bool correct_number_simplices = (num_simplices == 6);
+ return correct_number_simplices;
+}
+
+bool test_iterator_simplices4() {
+ Complex empty_complex;
+ for (auto v : empty_complex.vertex_range()) {
+ (void) v;
+ }
+ for (auto e : empty_complex.edge_range()) {
+ empty_complex[e];
+ }
+ for (auto t : empty_complex.triangle_range()) {
+ t.dimension();
+ }
+ for (auto s : empty_complex.complex_simplex_range()) {
+ s.dimension();
+ }
+ return true;
}
-bool test_iterator_simplices4(){
- Complex empty_complex;
- for(auto v : empty_complex.vertex_range()){
- (void) v;
- }
- for(auto e : empty_complex.edge_range()){
- empty_complex[e];
- }
- for(auto t : empty_complex.triangle_range()){
- t.dimension();
- }
- for(auto s : empty_complex.simplex_range()){
- s.dimension();
- }
- return true;
+bool test_iterator_coboundary() {
+ Complex c(4);
+ build_complete(4, c);
+ c.remove_edge(Vertex_handle(0), Vertex_handle(2));
+ PRINT(c.to_string());
+ Simplex s02(Vertex_handle(0), Vertex_handle(2));
+ int n = 0;
+ std::set<Simplex> expected;
+ expected.insert(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ expected.insert(Simplex(Vertex_handle(0), Vertex_handle(2), Vertex_handle(3)));
+ for (const auto & s : c.coboundary_range(s02)) {
+ PRINT(s);
+ if (expected.find(s) == expected.end())
+ return false;
+ ++n;
+ }
+ return n == 2;
}
-
template<typename Map>
-auto blocker_range(Map map) -> decltype( map | boost::adaptors::map_values){
- return map| boost::adaptors::map_values ;
-}
-
-
-bool test_iterator_blockers(){
- Complex complex;
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
-
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12)));
- complex.add_blocker(Simplex_handle(Vertex_handle(2),Vertex_handle(1),Vertex_handle(10)));
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(9),Vertex_handle(15)));
- complex.add_blocker(Simplex_handle(Vertex_handle(1),Vertex_handle(9),Vertex_handle(8)));
-
- // Print result
- int num_blockers=0;
- for(auto blockers : complex.blocker_range(Vertex_handle(10))){
- TESTVALUE(*blockers) ;
- num_blockers++;
- }
- bool test = (num_blockers==3);
-
- num_blockers=0;
- for (auto blockers : complex.blocker_range()){
- TESTVALUE(*blockers) ;
- num_blockers++;
- }
- test = test && (num_blockers==4) ;
-
- return test;
-}
-
-
-bool test_link0(){
-
- enum { a, b, c, d, n };
- Complex complex(n);
- complex.add_edge(Vertex_handle(b),Vertex_handle(c));complex.add_edge(Vertex_handle(c),Vertex_handle(d));
- Simplex_handle alpha = Simplex_handle(Vertex_handle(c));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
- PRINT(L.num_vertices());
- PRINT(L.to_string());
-
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(b)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(d)));
- bool test3 = L.num_edges()==0;
- bool test4 = L.num_blockers()==0;
- return test1&&test2&&test3&&test4;
-
-}
-
-bool test_link1(){
- Complex complex;
-
-
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- Simplex_handle alpha(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==0;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6(L.get_simplex_address(simplex));
- bool test7 = L.contains(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6&&test7 ;
-
-}
-
-
-bool test_link2(){
- Complex complex;
-
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(13)));
- alpha = Simplex_handle(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "L= Link_complex("<<alpha<<") : \n"<<L.to_string();
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==1;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6 ;
-}
-
-bool test_link3(){
- Complex complex;
-
- Simplex_handle alpha;
- Simplex_handle vertex_set_expected;
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12)));
- alpha = Simplex_handle(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // Print result
- cerr << "complex complex"<< complex.to_string();
- cerr <<endl<<endl;
- cerr << "L= Link_complex("<<alpha<<") : \n"<<L.to_string();
-
- auto L2 = complex.link(alpha);
- if(L!=L2) return false;
-
-
- // verification
- bool test = assert_vertex(L,*L.get_address(Root_vertex_handle(10)));
- test = test&& assert_vertex(L,*L.get_address(Root_vertex_handle(11)));
- test = test&& assert_vertex(L,*L.get_address(Root_vertex_handle(13)));
- test = test&& L.num_edges()==2;
- test = test&&L.contains_edge(*L.get_address(Root_vertex_handle(10)),*L.get_address(Root_vertex_handle(13)));
- test=test&&L.contains_edge(*L.get_address(Root_vertex_handle(13)),*L.get_address(Root_vertex_handle(11)));
- test=test&&L.num_blockers()==0;
- return test;
-}
-
-bool test_link4(){
- Complex complex;
-
- // Build the complexes
- for (int i=0;i<20;i++){
- complex.add_vertex();
- }
- for (int i=10;i<15;i++){
- for (int j=i+1;j<15;j++)
- complex.add_edge(Vertex_handle(i),Vertex_handle(j));
- }
- complex.add_blocker(Simplex_handle(Vertex_handle(10),Vertex_handle(11),Vertex_handle(12),Vertex_handle(13)));
- Simplex_handle alpha(Vertex_handle(12),Vertex_handle(14));
- Skeleton_blocker_link_complex<Complex> L(complex,alpha);
- // Complexes built
-
- // verification
- bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
- bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
- bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
- bool test4 = L.num_edges()==3;
- bool test5 = L.num_blockers()==1;
- Root_simplex_handle simplex;
- simplex.add_vertex(Root_vertex_handle(10));
- simplex.add_vertex(Root_vertex_handle(11));
- simplex.add_vertex(Root_vertex_handle(13));
- bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
- cerr <<"----> Ocomplex \n";
- return test1&&test2&&test3&&test4&&test5&&test6 ;
-
-}
-
-bool test_link5(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2),Vertex_handle(3)));
+auto blocker_range(Map map) -> decltype(map | boost::adaptors::map_values) {
+ return map | boost::adaptors::map_values;
+}
+
+bool test_iterator_blockers() {
+ Complex complex;
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12)));
+ complex.add_blocker(Simplex(Vertex_handle(2), Vertex_handle(1), Vertex_handle(10)));
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(9), Vertex_handle(15)));
+ complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(9), Vertex_handle(8)));
+
+ // Print result
+ int num_blockers = 0;
+ for (auto blockers : complex.blocker_range(Vertex_handle(10))) {
+ TESTVALUE(*blockers);
+ num_blockers++;
+ }
+ bool test = (num_blockers == 3);
+
+ num_blockers = 0;
+ for (auto blockers : complex.blocker_range()) {
+ TESTVALUE(*blockers);
+ num_blockers++;
+ }
+ test = test && (num_blockers == 4);
+
+ return test;
+}
+
+bool test_link0() {
+
+ enum {
+ a, b, c, d, n
+ };
+ Complex complex(n);
+ complex.add_edge_without_blockers(Vertex_handle(b), Vertex_handle(c));
+ complex.add_edge_without_blockers(Vertex_handle(c), Vertex_handle(d));
+ Simplex alpha = Simplex(Vertex_handle(c));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+ PRINT(L.num_vertices());
+ PRINT(L.to_string());
+
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(b)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(d)));
+ bool test3 = L.num_edges() == 0;
+ bool test4 = L.num_blockers() == 0;
+ return test1 && test2 && test3&&test4;
+
+}
+
+bool test_link1() {
+ Complex complex;
+
+
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ Simplex alpha(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 0;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6(L.get_simplex_address(simplex));
+ bool test7 = L.contains(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5 && test6&&test7;
+
+}
+
+bool test_link2() {
+ Complex complex;
+
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(13)));
+ alpha = Simplex(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string();
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 1;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5&&test6;
+}
+
+bool test_link3() {
+ Complex complex;
+
+ Simplex alpha;
+ Simplex vertex_set_expected;
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12)));
+ alpha = Simplex(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // Print result
+ cerr << "complex complex" << complex.to_string();
+ cerr << endl << endl;
+ cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string();
+
+ auto L2 = complex.link(alpha);
+ if (L != L2) return false;
+
+
+ // verification
+ bool test = assert_vertex(L, *L.get_address(Root_vertex_handle(10)));
+ test = test && assert_vertex(L, *L.get_address(Root_vertex_handle(11)));
+ test = test && assert_vertex(L, *L.get_address(Root_vertex_handle(13)));
+ test = test && L.num_edges() == 2;
+ test = test && L.contains_edge(*L.get_address(Root_vertex_handle(10)), *L.get_address(Root_vertex_handle(13)));
+ test = test && L.contains_edge(*L.get_address(Root_vertex_handle(13)), *L.get_address(Root_vertex_handle(11)));
+ test = test && L.num_blockers() == 0;
+ return test;
+}
+
+bool test_link4() {
+ Complex complex;
+
+ // Build the complexes
+ for (int i = 0; i < 20; i++) {
+ complex.add_vertex();
+ }
+ for (int i = 10; i < 15; i++) {
+ for (int j = i + 1; j < 15; j++)
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j));
+ }
+ complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12), Vertex_handle(13)));
+ Simplex alpha(Vertex_handle(12), Vertex_handle(14));
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha);
+ // Complexes built
+
+ // verification
+ bool test1 = L.contains_vertex(*L.get_address(Root_vertex_handle(10)));
+ bool test2 = L.contains_vertex(*L.get_address(Root_vertex_handle(11)));
+ bool test3 = L.contains_vertex(*L.get_address(Root_vertex_handle(13)));
+ bool test4 = L.num_edges() == 3;
+ bool test5 = L.num_blockers() == 1;
+ Root_simplex_handle simplex;
+ simplex.add_vertex(Root_vertex_handle(10));
+ simplex.add_vertex(Root_vertex_handle(11));
+ simplex.add_vertex(Root_vertex_handle(13));
+ bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex)));
+ cerr << "----> Ocomplex \n";
+ return test1 && test2 && test3 && test4 && test5&&test6;
+
+}
+
+bool test_link5() {
+ Complex complex(0, new Print_complex_visitor<Vertex_handle>());
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)));
+
+ Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
+
+
+ Skeleton_blocker_link_complex<Complex> L(complex, alpha); // Complexes built
+
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ PRINT(L.to_string());
+
+ // verification
+ return L.num_vertices() == 0;
+}
+
+bool test_link6() {
+ Complex complex(0, new Print_complex_visitor<Vertex_handle>());
+ // Build the complexes
+ build_complete(4, complex);
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
- Simplex_handle alpha(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2));
+ Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2));
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
- Skeleton_blocker_link_complex<Complex> L(complex,alpha); // Complexes built
+ build_link_of_blocker(complex, alpha, link_blocker_alpha);
+
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ PRINT(link_blocker_alpha.to_string());
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- PRINT(L.to_string());
-
- // verification
- return L.num_vertices()==0;
+ // verification
+ return link_blocker_alpha.num_vertices() == 1;
}
-bool test_link6(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(4,complex);
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
-
- Simplex_handle alpha(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2));
-
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
+bool test_link7() {
+ Complex complex(0, new Print_complex_visitor<Vertex_handle>());
+ // Build the complexes
+ build_complete(6, complex);
+ complex.add_vertex();
+ complex.add_vertex();
+ for (int i = 3; i < 6; ++i) {
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(6));
+ complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(7));
+ }
+ complex.add_edge_without_blockers(Vertex_handle(6), Vertex_handle(7));
+ complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)));
+ complex.add_blocker(Simplex(Vertex_handle(3), Vertex_handle(4), Vertex_handle(5)));
- build_link_of_blocker(complex,alpha,link_blocker_alpha);
-
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- PRINT(link_blocker_alpha.to_string());
-
- // verification
- return link_blocker_alpha.num_vertices()==1;
-}
+ Simplex alpha(Vertex_handle(3), Vertex_handle(4), Vertex_handle(5));
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
-bool test_link7(){
- Complex complex(0,new Print_complex_visitor<Vertex_handle>());
- // Build the complexes
- build_complete(6,complex);
- complex.add_vertex();
- complex.add_vertex();
- for(int i = 3; i<6; ++i){
- complex.add_edge(Vertex_handle(i),Vertex_handle(6));
- complex.add_edge(Vertex_handle(i),Vertex_handle(7));
- }
- complex.add_edge(Vertex_handle(6),Vertex_handle(7));
- complex.add_blocker(Simplex_handle(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2)));
- complex.add_blocker(Simplex_handle(Vertex_handle(3),Vertex_handle(4),Vertex_handle(5)));
+ build_link_of_blocker(complex, alpha, link_blocker_alpha);
- Simplex_handle alpha(Vertex_handle(3),Vertex_handle(4),Vertex_handle(5));
+ //the result should be the edge {6,7} plus the blocker {0,1,2}
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha;
+ // Print result
+ PRINT(complex.to_string());
+ cerr << endl << endl;
+ DBGVALUE(link_blocker_alpha.to_string());
- build_link_of_blocker(complex,alpha,link_blocker_alpha);
+ Skeleton_blocker_link_complex<Complex> link_blocker_alpha_cpy = link_blocker_alpha;
- //the result should be the edge {6,7} plus the blocker {0,1,2}
+ DBGVALUE(link_blocker_alpha_cpy.to_string());
- // Print result
- PRINT(complex.to_string());
- cerr <<endl<<endl;
- DBGVALUE(link_blocker_alpha.to_string());
+ bool equal_complexes =
+ (link_blocker_alpha.num_vertices() == link_blocker_alpha_cpy.num_vertices())
+ &&(link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers())
+ &&(link_blocker_alpha.num_edges() == link_blocker_alpha_cpy.num_edges())
+ ;
+ DBGVALUE((link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers()));
+ DBGVALUE((link_blocker_alpha.num_blockers()));
+ DBGVALUE((link_blocker_alpha_cpy.num_blockers()));
- Skeleton_blocker_link_complex<Complex> link_blocker_alpha_cpy = link_blocker_alpha;
+ DBGVALUE(equal_complexes);
- DBGVALUE(link_blocker_alpha_cpy.to_string());
-
- bool equal_complexes =
- (link_blocker_alpha.num_vertices() == link_blocker_alpha_cpy.num_vertices())
- &&(link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers())
- &&(link_blocker_alpha.num_edges() == link_blocker_alpha_cpy.num_edges())
- ;
- DBGVALUE((link_blocker_alpha.num_blockers() == link_blocker_alpha_cpy.num_blockers()));
- DBGVALUE((link_blocker_alpha.num_blockers() ));
- DBGVALUE(( link_blocker_alpha_cpy.num_blockers()));
-
- DBGVALUE(equal_complexes);
-
- // verification
- return link_blocker_alpha.num_vertices()==5 && link_blocker_alpha.num_edges()==4 && link_blocker_alpha.num_blockers()==1 && equal_complexes;
+ // verification
+ return link_blocker_alpha.num_vertices() == 5 && link_blocker_alpha.num_edges() == 4 && link_blocker_alpha.num_blockers() == 1 && equal_complexes;
}
-
-
-
-
-
-
-
template<typename SimplexHandle>
-void add_triangle_edges(int a,int b,int c,list<SimplexHandle>& simplices){
- typedef SimplexHandle Simplex_handle;
- typedef typename SimplexHandle::Vertex_handle Vertex_handle;
+void add_triangle_edges(int a, int b, int c, list<SimplexHandle>& simplices) {
+ typedef SimplexHandle Simplex;
+ typedef typename SimplexHandle::Vertex_handle Vertex_handle;
- simplices.push_back(Simplex_handle(Vertex_handle(a),Vertex_handle(b) ));
- simplices.push_back(Simplex_handle(Vertex_handle(b),Vertex_handle(c) ));
- simplices.push_back(Simplex_handle(Vertex_handle(c),Vertex_handle(a) ));
+ simplices.push_back(Simplex(Vertex_handle(a), Vertex_handle(b)));
+ simplices.push_back(Simplex(Vertex_handle(b), Vertex_handle(c)));
+ simplices.push_back(Simplex(Vertex_handle(c), Vertex_handle(a)));
}
template<typename SimplexHandle>
-void add_triangle(int a,int b,int c,list<SimplexHandle>& simplices){
- typedef SimplexHandle Simplex_handle;
- typedef typename SimplexHandle::Vertex_handle Vertex_handle;
- simplices.push_back(Simplex_handle(Vertex_handle(a),Vertex_handle(b),Vertex_handle(c)));
+void add_triangle(int a, int b, int c, list<SimplexHandle>& simplices) {
+ typedef SimplexHandle Simplex;
+ typedef typename SimplexHandle::Vertex_handle Vertex_handle;
+ simplices.push_back(Simplex(Vertex_handle(a), Vertex_handle(b), Vertex_handle(c)));
}
-bool test_constructor(){
- list <Simplex_handle> simplices;
-
- simplices.push_back(Simplex_handle(Vertex_handle(0)));
- simplices.push_back(Simplex_handle(Vertex_handle(1)));
- simplices.push_back(Simplex_handle(Vertex_handle(2)));
- simplices.push_back(Simplex_handle(Vertex_handle(3)));
- simplices.push_back(Simplex_handle(Vertex_handle(4)));
- simplices.push_back(Simplex_handle(Vertex_handle(5)));
+bool test_constructor() {
+ list <Simplex> simplices;
- simplices.push_back(Simplex_handle(Vertex_handle(3),Vertex_handle(5) ));
+ simplices.push_back(Simplex(Vertex_handle(0)));
+ simplices.push_back(Simplex(Vertex_handle(1)));
+ simplices.push_back(Simplex(Vertex_handle(2)));
+ simplices.push_back(Simplex(Vertex_handle(3)));
+ simplices.push_back(Simplex(Vertex_handle(4)));
+ simplices.push_back(Simplex(Vertex_handle(5)));
- add_triangle_edges(0,1,5,simplices);
- add_triangle_edges(1,2,3,simplices);
- add_triangle_edges(2,3,4,simplices);
- add_triangle_edges(1,3,4,simplices);
- add_triangle_edges(1,2,4,simplices);
-
-
- add_triangle(0,1,5,simplices);
- add_triangle(1,2,3,simplices);
- add_triangle(1,3,4,simplices);
- add_triangle(1,2,4,simplices);
- add_triangle(2,3,4,simplices);
-
- Complex complex(simplices.begin(),simplices.end());
-
- PRINT(complex.to_string());
-
- return ( complex.num_vertices()==6&&complex.num_edges()==10&& complex.num_blockers()==2);
-}
-
-
-list<Simplex_handle> subfaces(Simplex_handle top_face){
- list<Simplex_handle> res;
- if(top_face.dimension()==-1) return res;
- if(top_face.dimension()==0) {
- res.push_back(top_face);
- return res;
- }
- else{
- Vertex_handle first_vertex = top_face.first_vertex();
- top_face.remove_vertex(first_vertex);
- res = subfaces(top_face);
- list<Simplex_handle> copy = res;
- for(auto& simplex : copy){
- simplex.add_vertex(first_vertex);
- }
- res.push_back(Simplex_handle(first_vertex));
- res.splice(res.end(),copy);
- return res;
- }
-}
-
-
-bool test_constructor2(){
- Simplex_handle simplex;
- for(int i =0 ; i < 5;++i)
- simplex.add_vertex(static_cast<Vertex_handle>(i));
-
- list <Simplex_handle> simplices(subfaces(simplex));
- simplices.remove(simplex);
-
- Complex complex(simplices.begin(),simplices.end());
-
- PRINT(complex.to_string());
-
- for(auto b : complex.const_blocker_range()){
- cout << "b:"<<b<<endl;
- }
-
- return ( complex.num_vertices()==5&&complex.num_edges()==10&& complex.num_blockers()==1);
-}
+ simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(5)));
+ add_triangle_edges(0, 1, 5, simplices);
+ add_triangle_edges(1, 2, 3, simplices);
+ add_triangle_edges(2, 3, 4, simplices);
+ add_triangle_edges(1, 3, 4, simplices);
+ add_triangle_edges(1, 2, 4, simplices);
-bool test_constructor3(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2))));
- subf.pop_back(); //remove max face -> now a blocker 012
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
- DBGVALUE(complex.to_string());
+ add_triangle(0, 1, 5, simplices);
+ add_triangle(1, 2, 3, simplices);
+ add_triangle(1, 3, 4, simplices);
+ add_triangle(1, 2, 4, simplices);
+ add_triangle(2, 3, 4, simplices);
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(2));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
+ Complex complex(simplices.begin(), simplices.end());
+ PRINT(complex.to_string());
- return complex.num_vertices()==3 && complex.num_blockers()==1;
+ return ( complex.num_vertices() == 6 && complex.num_edges() == 10 && complex.num_blockers() == 2);
}
-bool test_constructor4(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2),Vh(3))));
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
-
- simplices.push_back(Sh(Vh(4)));
- simplices.push_back(Sh(Vh(4),Vh(1)));
- simplices.push_back(Sh(Vh(4),Vh(0)));
-
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
-
- DBGVALUE(complex.to_string());
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(4));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
-
- return complex.num_vertices()==5 && complex.num_blockers()==1 && complex.num_edges()==8;
+list<Simplex> subfaces(Simplex top_face) {
+ list<Simplex> res;
+ if (top_face.dimension() == -1) return res;
+ if (top_face.dimension() == 0) {
+ res.push_back(top_face);
+ return res;
+ } else {
+ Vertex_handle first_vertex = top_face.first_vertex();
+ top_face.remove_vertex(first_vertex);
+ res = subfaces(top_face);
+ list<Simplex> copy = res;
+ for (auto& simplex : copy) {
+ simplex.add_vertex(first_vertex);
+ }
+ res.push_back(Simplex(first_vertex));
+ res.splice(res.end(), copy);
+ return res;
+ }
}
+bool test_constructor2() {
+ Simplex simplex;
+ for (int i = 0; i < 5; ++i)
+ simplex.add_vertex(static_cast<Vertex_handle> (i));
+ list <Simplex> simplices(subfaces(simplex));
+ simplices.remove(simplex);
-bool test_constructor5(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2))));
- simplices.insert(simplices.begin(),subf.begin(),subf.end());
-
- simplices.push_back(Sh(Vh(3)));
- simplices.push_back(Sh(Vh(3),Vh(1)));
- simplices.push_back(Sh(Vh(3),Vh(2)));
- simplices.push_back(Sh(Vh(4)));
- simplices.push_back(Sh(Vh(4),Vh(1)));
- simplices.push_back(Sh(Vh(4),Vh(0)));
- simplices.push_back(Sh(Vh(5)));
- simplices.push_back(Sh(Vh(5),Vh(2)));
- simplices.push_back(Sh(Vh(5),Vh(0)));
-
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
+ Complex complex(simplices.begin(), simplices.end());
- DBGVALUE(complex.to_string());
+ PRINT(complex.to_string());
- return complex.num_vertices()==6 && complex.num_blockers()==3 && complex.num_edges()==9;
-}
-
-
-bool test_constructor6(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- auto subf(subfaces(Sh(Vh(0),Vh(1),Vh(2),Vh(3))));
- for(auto s:subf){
- Sh s1(Vh(0),Vh(1),Vh(2),Vh(3));
- Sh s2(Vh(1),Vh(2),Vh(3));
- if(s!=s1 && s!=s2) simplices.push_back(s);
- }
+ for (auto b : complex.const_blocker_range()) {
+ cout << "b:" << b << endl;
+ }
- DBGCONT(simplices);
- Complex complex(simplices.begin(),simplices.end());
-
- DBGVALUE(complex.to_string());
-
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(1),Vh(2),Vh(3));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
- return complex.num_vertices()==4 && complex.num_blockers()==1 && complex.num_edges()==6;
+ return ( complex.num_vertices() == 5 && complex.num_edges() == 10 && complex.num_blockers() == 1);
}
+bool test_constructor3() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2))));
+ subf.pop_back(); //remove max face -> now a blocker 012
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
-bool test_constructor7(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- simplices.push_back(Sh(Vh(0),Vh(1),Vh(2)));
- simplices.push_back(Sh(Vh(1),Vh(2),Vh(3)));
- simplices.push_back(Sh(Vh(3),Vh(0),Vh(2)));
- simplices.push_back(Sh(Vh(3),Vh(0),Vh(1)));
+ DBGVALUE(complex.to_string());
- //get complex from top faces
- Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(),simplices.end()));
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(2));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
- DBGVALUE(complex.to_string());
- if(complex.num_blockers()!=1) return false;
- Sh expected_blocker(Vh(0),Vh(1),Vh(2),Vh(3));
- for(auto b : complex.const_blocker_range())
- if(*b!=expected_blocker) return false;
- return complex.num_vertices()==4 && complex.num_blockers()==1 && complex.num_edges()==6;
+ return complex.num_vertices() == 3 && complex.num_blockers() == 1;
}
+bool test_constructor4() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2), Vh(3))));
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
-bool test_constructor8(){
- typedef Vertex_handle Vh;
- typedef Simplex_handle Sh;
- std::vector<Simplex_handle> simplices;
- simplices.push_back(Sh(Vh(0),Vh(1)));
- simplices.push_back(Sh(Vh(2),Vh(1)));
- simplices.push_back(Sh(Vh(0),Vh(2)));
- simplices.push_back(Sh(Vh(3),Vh(1)));
- simplices.push_back(Sh(Vh(2),Vh(3)));
+ simplices.push_back(Sh(Vh(4)));
+ simplices.push_back(Sh(Vh(4), Vh(1)));
+ simplices.push_back(Sh(Vh(4), Vh(0)));
- //get complex from top faces
- Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(),simplices.end()));
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
- DBGVALUE(complex.to_string());
+ DBGVALUE(complex.to_string());
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(4));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
- return complex.num_vertices()==4 && complex.num_blockers()==2 && complex.num_edges()==5;
+ return complex.num_vertices() == 5 && complex.num_blockers() == 1 && complex.num_edges() == 8;
}
-
-
-
-
-int main (int argc, char *argv[])
-{
- Tests tests_complex;
- tests_complex.add("test simplex",test_simplex);
- tests_complex.add("test_link0",test_link0);
- tests_complex.add("test_link1",test_link1);
- tests_complex.add("test_link2",test_link2);
- tests_complex.add("test_link3",test_link3);
- tests_complex.add("test_link4",test_link4);
- tests_complex.add("test_link5",test_link5);
- tests_complex.add("test_link6",test_link6);
- tests_complex.add("test_link7",test_link7);
-
- tests_complex.add("test iterator vertices 1",test_iterator_vertices1);
- tests_complex.add("test iterator vertices 2",test_iterator_vertices2);
- tests_complex.add("test iterator edges",test_iterator_edge);
- tests_complex.add("test iterator edges 2",test_iterator_edge2);
- tests_complex.add("test iterator edges 3",test_iterator_edge3);
-
- tests_complex.add("test iterator simplices",test_iterator_simplices);
- tests_complex.add("test iterator simplices2",test_iterator_simplices2);
- tests_complex.add("test iterator simplices3",test_iterator_simplices3);
- tests_complex.add("test iterator simplices4",test_iterator_simplices4);
-
-
- tests_complex.add("test iterator blockers",test_iterator_blockers);
- tests_complex.add("test_iterator_triangles",test_iterator_triangles);
-
- tests_complex.add("test_constructor_list_simplices",test_constructor);
- tests_complex.add("test_constructor_list_simplices2",test_constructor2);
- tests_complex.add("test_constructor_list_simplices3",test_constructor3);
- tests_complex.add("test_constructor_list_simplices4",test_constructor4);
- tests_complex.add("test_constructor_list_simplices5",test_constructor5);
- tests_complex.add("test_constructor_list_simplices6",test_constructor6);
- tests_complex.add("test_constructor_list_simplices7",test_constructor7);
- tests_complex.add("test_constructor_list_simplices8",test_constructor8);
-
-
- if(tests_complex.run()){
- return EXIT_SUCCESS;
- }
- else{
- return EXIT_FAILURE;
- }
-
- // test_iterator_simplices();
+bool test_constructor5() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2))));
+ simplices.insert(simplices.begin(), subf.begin(), subf.end());
+
+ simplices.push_back(Sh(Vh(3)));
+ simplices.push_back(Sh(Vh(3), Vh(1)));
+ simplices.push_back(Sh(Vh(3), Vh(2)));
+ simplices.push_back(Sh(Vh(4)));
+ simplices.push_back(Sh(Vh(4), Vh(1)));
+ simplices.push_back(Sh(Vh(4), Vh(0)));
+ simplices.push_back(Sh(Vh(5)));
+ simplices.push_back(Sh(Vh(5), Vh(2)));
+ simplices.push_back(Sh(Vh(5), Vh(0)));
+
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
+
+ DBGVALUE(complex.to_string());
+
+ return complex.num_vertices() == 6 && complex.num_blockers() == 3 && complex.num_edges() == 9;
+}
+
+bool test_constructor6() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ auto subf(subfaces(Sh(Vh(0), Vh(1), Vh(2), Vh(3))));
+ for (auto s : subf) {
+ Sh s1(Vh(0), Vh(1), Vh(2), Vh(3));
+ Sh s2(Vh(1), Vh(2), Vh(3));
+ if (s != s1 && s != s2) simplices.push_back(s);
+ }
+
+ DBGCONT(simplices);
+ Complex complex(simplices.begin(), simplices.end());
+
+ DBGVALUE(complex.to_string());
+
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(1), Vh(2), Vh(3));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
+ return complex.num_vertices() == 4 && complex.num_blockers() == 1 && complex.num_edges() == 6;
+}
+
+bool test_constructor7() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ simplices.push_back(Sh(Vh(0), Vh(1), Vh(2)));
+ simplices.push_back(Sh(Vh(1), Vh(2), Vh(3)));
+ simplices.push_back(Sh(Vh(3), Vh(0), Vh(2)));
+ simplices.push_back(Sh(Vh(3), Vh(0), Vh(1)));
+
+ //get complex from top faces
+ Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end()));
+
+ DBGVALUE(complex.to_string());
+
+ if (complex.num_blockers() != 1) return false;
+ Sh expected_blocker(Vh(0), Vh(1), Vh(2), Vh(3));
+ for (auto b : complex.const_blocker_range())
+ if (*b != expected_blocker) return false;
+ return complex.num_vertices() == 4 && complex.num_blockers() == 1 && complex.num_edges() == 6;
+}
+
+bool test_constructor8() {
+ typedef Vertex_handle Vh;
+ typedef Simplex Sh;
+ std::vector<Simplex> simplices;
+ simplices.push_back(Sh(Vh(0), Vh(1)));
+ simplices.push_back(Sh(Vh(2), Vh(1)));
+ simplices.push_back(Sh(Vh(0), Vh(2)));
+ simplices.push_back(Sh(Vh(3), Vh(1)));
+ simplices.push_back(Sh(Vh(2), Vh(3)));
+
+ //get complex from top faces
+ Complex complex(make_complex_from_top_faces<Complex>(simplices.begin(), simplices.end()));
+
+ DBGVALUE(complex.to_string());
+
+ return complex.num_vertices() == 4 && complex.num_blockers() == 2 && complex.num_edges() == 5;
+}
+
+int main(int argc, char *argv[]) {
+ Tests tests_complex;
+ tests_complex.add("test simplex", test_simplex);
+ tests_complex.add("test_link0", test_link0);
+ tests_complex.add("test_link1", test_link1);
+ tests_complex.add("test_link2", test_link2);
+ tests_complex.add("test_link3", test_link3);
+ tests_complex.add("test_link4", test_link4);
+ tests_complex.add("test_link5", test_link5);
+ tests_complex.add("test_link6", test_link6);
+ tests_complex.add("test_link7", test_link7);
+
+ tests_complex.add("test_constructor_list_simplices", test_constructor);
+ tests_complex.add("test_constructor_list_simplices2", test_constructor2);
+ tests_complex.add("test_constructor_list_simplices3", test_constructor3);
+ tests_complex.add("test_constructor_list_simplices4", test_constructor4);
+ tests_complex.add("test_constructor_list_simplices5", test_constructor5);
+ tests_complex.add("test_constructor_list_simplices6", test_constructor6);
+ tests_complex.add("test_constructor_list_simplices7", test_constructor7);
+ tests_complex.add("test_constructor_list_simplices8", test_constructor8);
+
+ tests_complex.add("test iterator vertices 1", test_iterator_vertices1);
+ tests_complex.add("test iterator vertices 2", test_iterator_vertices2);
+ tests_complex.add("test iterator edges", test_iterator_edge);
+ tests_complex.add("test iterator edges 2", test_iterator_edge2);
+ tests_complex.add("test iterator edges 3", test_iterator_edge3);
+ tests_complex.add("test iterator blockers", test_iterator_blockers);
+ tests_complex.add("test_iterator_triangles", test_iterator_triangles);
+ tests_complex.add("test iterator simplices", test_iterator_simplices);
+ tests_complex.add("test iterator simplices2", test_iterator_simplices2);
+ tests_complex.add("test iterator simplices3", test_iterator_simplices3);
+ tests_complex.add("test iterator simplices4", test_iterator_simplices4);
+ tests_complex.add("test iterator coboundary", test_iterator_coboundary);
+
+ if (tests_complex.run()) {
+ return EXIT_SUCCESS;
+ } else {
+ return EXIT_FAILURE;
+ }
+
+ // test_iterator_simplices();
}