From 6b1843bc5f19800433eedd288f2d966a985bcc16 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Sep 2016 07:26:41 +0000 Subject: Modify the Alpha complex doc wit a concept to create a simplicial complex from alpha complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1546 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d8083c3b0e03e1cf0033e5c7c1ba6f95618efdc1 --- .../concept/Simplicial_complex_for_alpha.h | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/Alpha_complex/concept/Simplicial_complex_for_alpha.h (limited to 'src/Alpha_complex/concept') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h new file mode 100644 index 00000000..2fd5dc03 --- /dev/null +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -0,0 +1,98 @@ +/* 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): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * 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 . + */ + +#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ +#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ + +namespace Gudhi { + +namespace alpha_complex { + +/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Alpha_complex`. + */ +struct SimplicialComplexForAlpha { + /** Handle to specify a simplex. */ + typedef unspecified Simplex_handle; + /** Handle to specify a vertex. Must be a non-negative integer. */ + typedef unspecified Vertex_handle; + /** Handle to specify the simplex filtration value. */ + typedef unspecified Filtration_value; + + /** Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + + /** Gets the simplicial complex dimension. */ + int dimension(); + + /** Sets the simplicial complex dimension. */ + void set_dimension(int dimension); + + /** Gets the 'simplex' dimension. */ + int dimension(Simplex_handle simplex); + + /** Assigns the 'simplex' with the given 'filtration' value. */ + int assign_filtration(Simplex_handle simplex, Filtration_value filtration); + + /** \brief Inserts a simplex with vertices from a given range 'vertex_range' in the simplicial complex with the given + * 'filtration' value. */ + template< typedef Input_vertex_range > + Insertion_result_type insert_simplex_and_subfaces(Input_vertex_range const & vertex_range, + Filtration_value filtration); + + /** Browses the simplicial complex to make the filtration non-decreasing. */ + void make_filtration_non_decreasing(); + + /** Prune the simplicial complex above 'filtration' value given as parameter. */ + void prune_above_filtration(Filtration_value filtration); + + /** Sorts the filtration values in the simplicial complex. */ + void initialize_filtration(); + + /** \brief Iterator over vertices of a simplex. + * + * 'value type' must be 'Vertex_handle'.*/ + typedef unspecified Simplex_vertex_range; + + /** \brief Returns a range over vertices of a given + * simplex. */ + Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); + + /** \brief Iterator over the boundaries of the complex, in an arbitrary order. + * + * 'value_type' must be 'Simplex_handle'.*/ + typedef unspecified Boundary_simplex_range; + + /** \brief Returns a range over boundaries of a given simplex. */ + Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); + + /** \brief Return type of an insertion of a simplex + */ + typedef unspecified Insertion_result_type; + +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ -- cgit v1.2.3 From 0101a149fc124d62f8a4966654fa30e01f57d424 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Sep 2016 09:37:35 +0000 Subject: Fix cpplints git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1548 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b8d7d5b4bde8aeec92d6bfc79b8c146c551317c0 --- src/Alpha_complex/concept/Simplicial_complex_for_alpha.h | 7 +++---- src/Alpha_complex/example/Alpha_complex_from_off.cpp | 7 ++++--- src/Alpha_complex/example/Alpha_complex_from_points.cpp | 2 +- src/Alpha_complex/include/gudhi/Alpha_complex.h | 6 +++--- .../example/alpha_complex_persistence.cpp | 8 ++++---- .../example/custom_persistence_sort.cpp | 14 +++++++------- 6 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/Alpha_complex/concept') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h index 2fd5dc03..384ac2eb 100644 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -40,7 +40,7 @@ struct SimplicialComplexForAlpha { /** Returns the number of vertices in the simplicial complex. */ std::size_t num_vertices(); - + /** Gets the simplicial complex dimension. */ int dimension(); @@ -61,10 +61,10 @@ struct SimplicialComplexForAlpha { /** Browses the simplicial complex to make the filtration non-decreasing. */ void make_filtration_non_decreasing(); - + /** Prune the simplicial complex above 'filtration' value given as parameter. */ void prune_above_filtration(Filtration_value filtration); - + /** Sorts the filtration values in the simplicial complex. */ void initialize_filtration(); @@ -88,7 +88,6 @@ struct SimplicialComplexForAlpha { /** \brief Return type of an insertion of a simplex */ typedef unspecified Insertion_result_type; - }; } // namespace alpha_complex diff --git a/src/Alpha_complex/example/Alpha_complex_from_off.cpp b/src/Alpha_complex/example/Alpha_complex_from_off.cpp index 31f8e10c..32bef1cd 100644 --- a/src/Alpha_complex/example/Alpha_complex_from_off.cpp +++ b/src/Alpha_complex/example/Alpha_complex_from_off.cpp @@ -39,15 +39,16 @@ int main(int argc, char **argv) { Gudhi::Simplex_tree<> simplex; if (alpha_complex_from_file.create_complex(simplex, alpha_square_max_value)) { std::ostream output_stream(streambufffer); - + // ---------------------------------------------------------------------------- // Display information about the alpha complex // ---------------------------------------------------------------------------- output_stream << "Alpha complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices() << " simplices - " << simplex.num_vertices() << " vertices." << std::endl; - - output_stream << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; + + output_stream << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << + std::endl; for (auto f_simplex : simplex.filtration_simplex_range()) { output_stream << " ( "; for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { diff --git a/src/Alpha_complex/example/Alpha_complex_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_from_points.cpp index fa3c1efc..491b7e6d 100644 --- a/src/Alpha_complex/example/Alpha_complex_from_points.cpp +++ b/src/Alpha_complex/example/Alpha_complex_from_points.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) { std::cout << "Alpha complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices() << " simplices - " << simplex.num_vertices() << " vertices." << std::endl; - + std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : simplex.filtration_simplex_range()) { std::cout << " ( "; diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index ab96531f..8bb6af1f 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -232,7 +232,7 @@ class Alpha_complex { typedef typename SimplicialComplexForAlpha::Vertex_handle Vertex_handle; typedef typename SimplicialComplexForAlpha::Simplex_handle Simplex_handle; typedef std::vector Vector_vertex; - + if (triangulation_ == nullptr) { std::cerr << "Alpha_complex cannot create_complex from a NULL triangulation\n"; return false; // ----- >> @@ -249,7 +249,7 @@ class Alpha_complex { std::cerr << "Alpha_complex create_complex - complex is not empty\n"; return false; // ----- >> } - + complex.set_dimension(triangulation_->maximal_dimension()); // -------------------------------------------------------------------------------------------- @@ -353,7 +353,7 @@ class Alpha_complex { #ifdef DEBUG_TRACES typedef typename SimplicialComplexForAlpha::Vertex_handle Vertex_handle; #endif // DEBUG_TRACES - + // ### Foreach Tau face of Sigma for (auto f_boundary : complex.boundary_simplex_range(f_simplex)) { #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp index 44eda6aa..2412569a 100644 --- a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp @@ -42,19 +42,19 @@ int main(int argc, char **argv) { std::cout << "Simplicial complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices() << " simplices - " << simplex.num_vertices() << " vertices." << std::endl; - + // Sort the simplices in the order of the filtration simplex.initialize_filtration(); - + std::cout << "Simplex_tree dim: " << simplex.dimension() << std::endl; // Compute the persistence diagram of the complex Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>, Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); - + pcoh.compute_persistent_cohomology(min_persistence); - + // Output the diagram in filediag if (output_file_diag.empty()) { pcoh.output_diagram(); diff --git a/src/Persistent_cohomology/example/custom_persistence_sort.cpp b/src/Persistent_cohomology/example/custom_persistence_sort.cpp index 8e254700..64f2a4dc 100644 --- a/src/Persistent_cohomology/example/custom_persistence_sort.cpp +++ b/src/Persistent_cohomology/example/custom_persistence_sort.cpp @@ -97,18 +97,18 @@ int main(int argc, char **argv) { std::cout << "Simplicial complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices() << " simplices - " << simplex.num_vertices() << " vertices." << std::endl; - + // Sort the simplices in the order of the filtration simplex.initialize_filtration(); - + std::cout << "Simplex_tree dim: " << simplex.dimension() << std::endl; - + Persistent_cohomology pcoh(simplex); - + // initializes the coefficient field for homology - Z/3Z pcoh.init_coefficients(3); pcoh.compute_persistent_cohomology(0.2); - + // Custom sort and output persistence cmp_intervals_by_dim_then_length cmp(&simplex); auto persistent_pairs = pcoh.get_persistent_pairs(); @@ -118,13 +118,13 @@ int main(int argc, char **argv) { << simplex.filtration(get<0>(pair)) << " " << simplex.filtration(get<1>(pair)) << std::endl; } - + // Persistent Betti numbers std::cout << "The persistent Betti numbers in interval [0.40, 0.41] are : "; for (int dim = 0; dim < simplex.dimension(); dim++) std::cout << "b" << dim << " = " << pcoh.persistent_betti_number(dim, 0.40, 0.41) << " ; "; std::cout << std::endl; - + // Betti numbers std::vector betti_numbers = pcoh.betti_numbers(); std::cout << "The Betti numbers are : "; -- cgit v1.2.3 From e17f35542e727a75f123c9454726a85673879655 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 3 Oct 2016 13:28:28 +0000 Subject: Precise insert_simplex_and_subfaces concept git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1607 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8686088820bac273354d451b237953f984c7bd02 --- src/Alpha_complex/concept/Simplicial_complex_for_alpha.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/Alpha_complex/concept') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h index 384ac2eb..24aab215 100644 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -53,11 +53,9 @@ struct SimplicialComplexForAlpha { /** Assigns the 'simplex' with the given 'filtration' value. */ int assign_filtration(Simplex_handle simplex, Filtration_value filtration); - /** \brief Inserts a simplex with vertices from a given range 'vertex_range' in the simplicial complex with the given - * 'filtration' value. */ - template< typedef Input_vertex_range > - Insertion_result_type insert_simplex_and_subfaces(Input_vertex_range const & vertex_range, - Filtration_value filtration); + /** \brief Inserts a simplex with vertices from a given simplex (represented by a vector of Vertex_handle) in the + * simplicial complex with the given 'filtration' value. */ + void insert_simplex_and_subfaces(std::vector const & vertex_range, Filtration_value filtration); /** Browses the simplicial complex to make the filtration non-decreasing. */ void make_filtration_non_decreasing(); -- cgit v1.2.3 From 66cdca82e9ca86fcdfa2a08c6003a5661d802cf3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 3 Oct 2016 13:39:50 +0000 Subject: No need of complex.dimension(void). It reduces the concept. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1608 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 95cf6a9b453349e032c1d553bb9b5c3981c92b0a --- src/Alpha_complex/concept/Simplicial_complex_for_alpha.h | 3 --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src/Alpha_complex/concept') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h index 24aab215..0cbf1769 100644 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -41,9 +41,6 @@ struct SimplicialComplexForAlpha { /** Returns the number of vertices in the simplicial complex. */ std::size_t num_vertices(); - /** Gets the simplicial complex dimension. */ - int dimension(); - /** Sets the simplicial complex dimension. */ void set_dimension(int dimension); diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index cda40021..0613ca7c 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -292,7 +292,7 @@ class Alpha_complex { // Will be re-used many times Vector_of_CGAL_points pointVector; // ### For i : d -> 0 - for (int decr_dim = complex.dimension(); decr_dim >= 0; decr_dim--) { + for (int decr_dim = triangulation_->maximal_dimension(); decr_dim >= 0; decr_dim--) { // ### Foreach Sigma of dim i for (Simplex_handle f_simplex : complex.skeleton_simplex_range(decr_dim)) { int f_simplex_dim = complex.dimension(f_simplex); -- cgit v1.2.3 From 1693786349ba3a3c7ca003d8a2e8afd6f0556539 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 5 Oct 2016 20:57:19 +0000 Subject: Fix review comments git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1648 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: de0b4f12b6eb814224df13c5cec1069310115efa --- .../concept/Simplicial_complex_for_alpha.h | 3 - src/Alpha_complex/include/gudhi/Alpha_complex.h | 77 ++++++++++------------ src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 29 ++++++++ 3 files changed, 63 insertions(+), 46 deletions(-) (limited to 'src/Alpha_complex/concept') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h index 0cbf1769..2b8bff94 100644 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -60,9 +60,6 @@ struct SimplicialComplexForAlpha { /** Prune the simplicial complex above 'filtration' value given as parameter. */ void prune_above_filtration(Filtration_value filtration); - /** Sorts the filtration values in the simplicial complex. */ - void initialize_filtration(); - /** \brief Iterator over vertices of a simplex. * * 'value type' must be 'Vertex_handle'.*/ diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index ffcd26a3..69142a58 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -175,30 +175,28 @@ class Alpha_complex { void init_from_range(const InputPointRange& points) { auto first = std::begin(points); auto last = std::end(points); - if (first != last) { - // point_dimension function initialization - Point_Dimension point_dimension = kernel_.point_dimension_d_object(); + // point_dimension function initialization + Point_Dimension point_dimension = kernel_.point_dimension_d_object(); - // Delaunay triangulation is point dimension. - triangulation_ = new Delaunay_triangulation(point_dimension(*first)); + // Delaunay triangulation is point dimension. + triangulation_ = new Delaunay_triangulation(point_dimension(*first)); - std::vector points(first, last); + std::vector point_cloud(first, last); - // Creates a vector {0, 1, ..., N-1} - std::vector indices(boost::counting_iterator(0), - boost::counting_iterator(points.size())); + // Creates a vector {0, 1, ..., N-1} + std::vector indices(boost::counting_iterator(0), + boost::counting_iterator(point_cloud.size())); - // Sort indices considering CGAL spatial sort - typedef CGAL::Spatial_sort_traits_adapter_d Search_traits_d; - spatial_sort(indices.begin(), indices.end(), Search_traits_d(&(points[0]))); + // Sort indices considering CGAL spatial sort + typedef CGAL::Spatial_sort_traits_adapter_d Search_traits_d; + spatial_sort(indices.begin(), indices.end(), Search_traits_d(&(point_cloud[0]))); - typename Delaunay_triangulation::Full_cell_handle hint; - for (auto index : indices) { - typename Delaunay_triangulation::Vertex_handle pos = triangulation_->insert(points[index], hint); - // Save index value as data to retrieve it after insertion - pos->data() = index; - hint = pos->full_cell(); - } + typename Delaunay_triangulation::Full_cell_handle hint; + for (auto index : indices) { + typename Delaunay_triangulation::Vertex_handle pos = triangulation_->insert(point_cloud[index], hint); + // Save index value as data to retrieve it after insertion + pos->data() = index; + hint = pos->full_cell(); } } @@ -219,8 +217,7 @@ class Alpha_complex { * * @return true if creation succeeds, false otherwise. * - * @pre Delaunay triangulation must be already constructed with at least one vertex and dimension must be more - * than 0. + * @pre Delaunay triangulation must be already constructed with dimension strictly greater than 0. * @pre The simplicial complex must be empty (no vertices) * * Initialization can be launched once. @@ -236,10 +233,6 @@ class Alpha_complex { std::cerr << "Alpha_complex cannot create_complex from a NULL triangulation\n"; return false; // ----- >> } - if (triangulation_->number_of_vertices() < 1) { - std::cerr << "Alpha_complex cannot create_complex from a triangulation without vertices\n"; - return false; // ----- >> - } if (triangulation_->maximal_dimension() < 1) { std::cerr << "Alpha_complex cannot create_complex from a zero-dimension triangulation\n"; return false; // ----- >> @@ -266,25 +259,27 @@ class Alpha_complex { // -------------------------------------------------------------------------------------------- // Simplex_tree construction from loop on triangulation finite full cells list - for (auto cit = triangulation_->finite_full_cells_begin(); cit != triangulation_->finite_full_cells_end(); ++cit) { - Vector_vertex vertexVector; + if (triangulation_->number_of_vertices() > 0) { + for (auto cit = triangulation_->finite_full_cells_begin(); cit != triangulation_->finite_full_cells_end(); ++cit) { + Vector_vertex vertexVector; #ifdef DEBUG_TRACES - std::cout << "Simplex_tree insertion "; + std::cout << "Simplex_tree insertion "; #endif // DEBUG_TRACES - for (auto vit = cit->vertices_begin(); vit != cit->vertices_end(); ++vit) { - if (*vit != nullptr) { + for (auto vit = cit->vertices_begin(); vit != cit->vertices_end(); ++vit) { + if (*vit != nullptr) { #ifdef DEBUG_TRACES - std::cout << " " << (*vit)->data(); + std::cout << " " << (*vit)->data(); #endif // DEBUG_TRACES - // Vector of vertex construction for simplex_tree structure - vertexVector.push_back((*vit)->data()); + // Vector of vertex construction for simplex_tree structure + vertexVector.push_back((*vit)->data()); + } } - } #ifdef DEBUG_TRACES - std::cout << std::endl; + std::cout << std::endl; #endif // DEBUG_TRACES - // Insert each simplex and its subfaces in the simplex tree - filtration is NaN - complex.insert_simplex_and_subfaces(vertexVector, std::numeric_limits::quiet_NaN()); + // Insert each simplex and its subfaces in the simplex tree - filtration is NaN + complex.insert_simplex_and_subfaces(vertexVector, std::numeric_limits::quiet_NaN()); + } } // -------------------------------------------------------------------------------------------- @@ -333,13 +328,9 @@ class Alpha_complex { // -------------------------------------------------------------------------------------------- // As Alpha value is an approximation, we have to make filtration non decreasing while increasing the dimension - bool modified_filt = complex.make_filtration_non_decreasing(); + complex.make_filtration_non_decreasing(); // Remove all simplices that have a filtration value greater than max_alpha_square - // Remark: prune_above_filtration does not require initialize_filtration to be done before. - modified_filt |= complex.prune_above_filtration(max_alpha_square); - if (modified_filt) { - complex.initialize_filtration(); - } + complex.prune_above_filtration(max_alpha_square); // -------------------------------------------------------------------------------------------- return true; } diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 0d4132f8..b03851d1 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -235,3 +235,32 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { } } + +BOOST_AUTO_TEST_CASE(Alpha_complex_from_empty_points) { + // ---------------------------------------------------------------------------- + // Init of a list of points + // ---------------------------------------------------------------------------- + Vector_of_points points; + + // ---------------------------------------------------------------------------- + // Init of an alpha complex from the list of points + // ---------------------------------------------------------------------------- + Gudhi::alpha_complex::Alpha_complex alpha_complex_from_points(points); + + std::cout << "========== Alpha_complex_from_empty_points ==========" << std::endl; + + Gudhi::Simplex_tree<> simplex_tree; + BOOST_CHECK(alpha_complex_from_points.create_complex(simplex_tree)); + + std::cout << "simplex_tree.num_simplices()=" << simplex_tree.num_simplices() << std::endl; + BOOST_CHECK(simplex_tree.num_simplices() == 0); + + std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; + BOOST_CHECK(simplex_tree.dimension() == 4); + + std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; + BOOST_CHECK(simplex_tree.num_vertices() == 0); + + // Test to the limit + BOOST_CHECK_THROW (alpha_complex_from_points.get_point(0), std::out_of_range); +} -- cgit v1.2.3 From a424f92e94783648422edbd639da19d92a94cf90 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 31 Jan 2017 21:35:37 +0000 Subject: Rename Rips and Alpha concept file names GUDHI version 2.0.0 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_doc_2.0.0@2038 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: be93fae5a69b15de05bfabe75a2d84ef606b589f --- CMakeGUDHIVersion.txt | 6 +- .../concept/SimplicialComplexForAlpha.h | 89 ++++++++++++++++++++++ .../concept/Simplicial_complex_for_alpha.h | 89 ---------------------- .../concept/SimplicialComplexForRips.h | 54 +++++++++++++ .../concept/Simplicial_complex_for_rips.h | 54 ------------- src/common/doc/main_page.h | 6 +- 6 files changed, 149 insertions(+), 149 deletions(-) create mode 100644 src/Alpha_complex/concept/SimplicialComplexForAlpha.h delete mode 100644 src/Alpha_complex/concept/Simplicial_complex_for_alpha.h create mode 100644 src/Rips_complex/concept/SimplicialComplexForRips.h delete mode 100644 src/Rips_complex/concept/Simplicial_complex_for_rips.h (limited to 'src/Alpha_complex/concept') diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index a00ae1b2..bd0c57ac 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ -set (GUDHI_MAJOR_VERSION 1) -set (GUDHI_MINOR_VERSION 3) -set (GUDHI_PATCH_VERSION 1) +set (GUDHI_MAJOR_VERSION 2) +set (GUDHI_MINOR_VERSION 0) +set (GUDHI_PATCH_VERSION 0) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/Alpha_complex/concept/SimplicialComplexForAlpha.h b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h new file mode 100644 index 00000000..2b8bff94 --- /dev/null +++ b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h @@ -0,0 +1,89 @@ +/* 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): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * 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 . + */ + +#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ +#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ + +namespace Gudhi { + +namespace alpha_complex { + +/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Alpha_complex`. + */ +struct SimplicialComplexForAlpha { + /** Handle to specify a simplex. */ + typedef unspecified Simplex_handle; + /** Handle to specify a vertex. Must be a non-negative integer. */ + typedef unspecified Vertex_handle; + /** Handle to specify the simplex filtration value. */ + typedef unspecified Filtration_value; + + /** Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + + /** Sets the simplicial complex dimension. */ + void set_dimension(int dimension); + + /** Gets the 'simplex' dimension. */ + int dimension(Simplex_handle simplex); + + /** Assigns the 'simplex' with the given 'filtration' value. */ + int assign_filtration(Simplex_handle simplex, Filtration_value filtration); + + /** \brief Inserts a simplex with vertices from a given simplex (represented by a vector of Vertex_handle) in the + * simplicial complex with the given 'filtration' value. */ + void insert_simplex_and_subfaces(std::vector const & vertex_range, Filtration_value filtration); + + /** Browses the simplicial complex to make the filtration non-decreasing. */ + void make_filtration_non_decreasing(); + + /** Prune the simplicial complex above 'filtration' value given as parameter. */ + void prune_above_filtration(Filtration_value filtration); + + /** \brief Iterator over vertices of a simplex. + * + * 'value type' must be 'Vertex_handle'.*/ + typedef unspecified Simplex_vertex_range; + + /** \brief Returns a range over vertices of a given + * simplex. */ + Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); + + /** \brief Iterator over the boundaries of the complex, in an arbitrary order. + * + * 'value_type' must be 'Simplex_handle'.*/ + typedef unspecified Boundary_simplex_range; + + /** \brief Returns a range over boundaries of a given simplex. */ + Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); + + /** \brief Return type of an insertion of a simplex + */ + typedef unspecified Insertion_result_type; +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h deleted file mode 100644 index 2b8bff94..00000000 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ /dev/null @@ -1,89 +0,0 @@ -/* 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): Vincent Rouvreau - * - * Copyright (C) 2016 INRIA - * - * 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 . - */ - -#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ -#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ - -namespace Gudhi { - -namespace alpha_complex { - -/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial - * complex, that can be created from a `Alpha_complex`. - */ -struct SimplicialComplexForAlpha { - /** Handle to specify a simplex. */ - typedef unspecified Simplex_handle; - /** Handle to specify a vertex. Must be a non-negative integer. */ - typedef unspecified Vertex_handle; - /** Handle to specify the simplex filtration value. */ - typedef unspecified Filtration_value; - - /** Returns the number of vertices in the simplicial complex. */ - std::size_t num_vertices(); - - /** Sets the simplicial complex dimension. */ - void set_dimension(int dimension); - - /** Gets the 'simplex' dimension. */ - int dimension(Simplex_handle simplex); - - /** Assigns the 'simplex' with the given 'filtration' value. */ - int assign_filtration(Simplex_handle simplex, Filtration_value filtration); - - /** \brief Inserts a simplex with vertices from a given simplex (represented by a vector of Vertex_handle) in the - * simplicial complex with the given 'filtration' value. */ - void insert_simplex_and_subfaces(std::vector const & vertex_range, Filtration_value filtration); - - /** Browses the simplicial complex to make the filtration non-decreasing. */ - void make_filtration_non_decreasing(); - - /** Prune the simplicial complex above 'filtration' value given as parameter. */ - void prune_above_filtration(Filtration_value filtration); - - /** \brief Iterator over vertices of a simplex. - * - * 'value type' must be 'Vertex_handle'.*/ - typedef unspecified Simplex_vertex_range; - - /** \brief Returns a range over vertices of a given - * simplex. */ - Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); - - /** \brief Iterator over the boundaries of the complex, in an arbitrary order. - * - * 'value_type' must be 'Simplex_handle'.*/ - typedef unspecified Boundary_simplex_range; - - /** \brief Returns a range over boundaries of a given simplex. */ - Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); - - /** \brief Return type of an insertion of a simplex - */ - typedef unspecified Insertion_result_type; -}; - -} // namespace alpha_complex - -} // namespace Gudhi - -#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ diff --git a/src/Rips_complex/concept/SimplicialComplexForRips.h b/src/Rips_complex/concept/SimplicialComplexForRips.h new file mode 100644 index 00000000..7dab0615 --- /dev/null +++ b/src/Rips_complex/concept/SimplicialComplexForRips.h @@ -0,0 +1,54 @@ +/* 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): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * 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 . + */ + +#ifndef CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ +#define CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ + +namespace Gudhi { + +namespace rips_complex { + +/** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. + */ +struct SimplicialComplexForRips { + /** \brief Type used to store the filtration values of the simplicial complex. */ + typedef unspecified Filtration_value; + + /** \brief Inserts a given `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ + template + void insert_graph(const OneSkeletonGraph& skel_graph); + + /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as + * explained in \ref ripsdefinition. */ + void expansion(int max_dim); + + /** \brief Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + +}; + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h deleted file mode 100644 index 7dab0615..00000000 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ /dev/null @@ -1,54 +0,0 @@ -/* 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): Vincent Rouvreau - * - * Copyright (C) 2016 INRIA - * - * 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 . - */ - -#ifndef CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ -#define CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ - -namespace Gudhi { - -namespace rips_complex { - -/** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial - * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. - */ -struct SimplicialComplexForRips { - /** \brief Type used to store the filtration values of the simplicial complex. */ - typedef unspecified Filtration_value; - - /** \brief Inserts a given `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ - template - void insert_graph(const OneSkeletonGraph& skel_graph); - - /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as - * explained in \ref ripsdefinition. */ - void expansion(int max_dim); - - /** \brief Returns the number of vertices in the simplicial complex. */ - std::size_t num_vertices(); - -}; - -} // namespace rips_complex - -} // namespace Gudhi - -#endif // CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 60c9cd07..5e8f1dd7 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -62,7 +62,7 @@ Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
@@ -118,7 +118,7 @@ Author: Clément Jamin
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
@@ -155,7 +155,7 @@ Author: François Godi
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
Requires: \ref cgal ≥ 4.8.0 and \ref eigen3 -- cgit v1.2.3