From af146a2e48c16855355ac599cbc617250727d244 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Nov 2016 16:00:19 +0000 Subject: Add of tangential complex doc Separate simplex tree from alpha complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1788 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1cf4a35e0a099501eb1cb6b9809041dd1a1e2617 --- src/cython/doc/tangential_complex_user.rst | 144 +++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 src/cython/doc/tangential_complex_user.rst (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst new file mode 100644 index 00000000..588de08c --- /dev/null +++ b/src/cython/doc/tangential_complex_user.rst @@ -0,0 +1,144 @@ +============================== +Tangential complex user manual +============================== +.. include:: tangential_complex_sum.rst + +Definition +---------- + +A Tangential Delaunay complex is a simplicial complex designed to reconstruct a +:math:`k`-dimensional smooth manifold embedded in :math:`d`-dimensional +Euclidean space. The input is a point sample coming from an unknown manifold, +which means that the points lie close to a structure of "small" intrinsic +dimension. The running time depends only linearly on the extrinsic dimension +:math:`d` and exponentially on the intrinsic dimension :math:`k`. + +An extensive description of the Tangential complex can be found in +:cite:`tangentialcomplex2014`). + +What is a Tangential Complex? +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Let us start with the description of the Tangential complex of a simple +example, with :math:`k = 1` and :math:`d = 2`. The input data is 4 points +:math:`P` located on a curve embedded in 2D. + +.. figure:: img/tc_example_01.png + :alt: The input + :figclass: align-center + The input + +For each point :math:`p`, estimate its tangent subspace :math:`T_p` (e.g. +using PCA). + +.. figure:: img/tc_example_02.png + :alt: The estimated normals + :figclass: align-center + The estimated normals + +Let us add the Voronoi diagram of the points in orange. For each point +:math:`p`, construct its star in the Delaunay triangulation of :math:`P` +restricted to :math:`T_p`. + +.. figure:: img/tc_example_03.png + :alt: The Voronoi diagram + :figclass: align-center + The Voronoi diagram + +The Tangential Delaunay complex is the union of those stars. + +In practice, neither the ambient Voronoi diagram nor the ambient Delaunay +triangulation is computed. Instead, local :math:`k`-dimensional regular +triangulations are computed with a limited number of points as we only need the +star of each point. More details can be found in :cite:`tangentialcomplex2014`. + +Inconsistencies +^^^^^^^^^^^^^^^ +Inconsistencies between the stars can occur. An inconsistency occurs when a +simplex is not in the star of all its vertices. + +Let us take the same example. + +.. figure:: img/tc_example_07_before.png + :alt: Before + :figclass: align-center + Before + +Let us slightly move the tangent subspace :math:`T_q` + +.. figure:: img/tc_example_07_after.png + :alt: After + :figclass: align-center + After + +Now, the star of :math:`Q` contains :math:`QP`, but the star of :math:`P` does +not contain :math:`QP`. We have an inconsistency. + +.. figure:: img/tc_example_08.png + :alt: After + :figclass: align-center + After + +One way to solve inconsistencies is to randomly perturb the positions of the +points involved in an inconsistency. In the current implementation, this +perturbation is done in the tangent subspace of each point. The maximum +perturbation radius is given as a parameter to the constructor. + +In most cases, we recommend to provide a point set where the minimum distance +between any two points is not too small. This can be achieved using the +functions provided by the Subsampling module. Then, a good value to start with +for the maximum perturbation radius would be around half the minimum distance +between any two points. The Example with perturbation below shows an example of +such a process. + +In most cases, this process is able to dramatically reduce the number of +inconsistencies, but is not guaranteed to succeed. + +Output +^^^^^^ +The result of the computation is exported as a Simplex_tree. It is the union of +the stars of all the input points. A vertex in the Simplex Tree is the index of +the point in the range provided by the user. The point corresponding to a +vertex can also be obtained through the Tangential_complex::get_point function. +Note that even if the positions of the points are perturbed, their original +positions are kept (e.g. Tangential_complex::get_point returns the original +position of the point). + +The result can be obtained after the computation of the Tangential complex +itself and/or after the perturbation process. + + +Simple example +-------------- + +This example builds the Tangential complex of point set. Note that the +dimension of the kernel here is dynamic, which is slower, but more flexible: +the intrinsic and ambient dimensions does not have to be known at compile-time. + +testcode:: + + import gudhi + tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + +The output is: + +testoutput:: + + Tangential complex is of dimension 2 - 25 simplices - 7 vertices. + + +Example with perturbation +------------------------- + +This example builds the Tangential complex of a point set, then tries to solve +inconsistencies by perturbing the positions of points involved in inconsistent +simplices. + +testcode:: + + import gudhi + tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + +The output is: + +testoutput:: -- cgit v1.2.3 From 97d80185d6ec4d5e8f81b4cd4936d29a6d63b05b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 29 Nov 2016 16:50:55 +0000 Subject: Fix interface for Alpha complex and Tangential complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1801 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 995b53c7f65057ec155988b90f17299665eab4ae --- .../include/gudhi/Tangential_complex/config.h | 3 +- src/cython/CMakeLists.txt | 4 ++ src/cython/cython/alpha_complex.pyx | 19 ++++---- src/cython/cython/simplex_tree.pyx | 48 ++++++++++++-------- src/cython/cython/tangential_complex.pyx | 12 +++-- src/cython/doc/alpha_complex_user.rst | 14 +++--- .../doc/persistence_graphical_tools_user.rst | 3 +- src/cython/doc/tangential_complex_user.rst | 53 ++++++++++++++++++---- ...ex_diagram_persistence_from_off_file_example.py | 3 +- .../example/alpha_complex_from_points_example.py | 3 +- src/cython/include/Alpha_complex_interface.h | 6 +-- src/cython/include/Tangential_complex_interface.h | 14 +++--- src/cython/test/test_alpha_complex.py | 6 +-- 13 files changed, 116 insertions(+), 72 deletions(-) (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h index 98a1b14f..ffefcd6b 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h @@ -26,8 +26,7 @@ #include // ========================= Debugging & profiling ============================= -#define GUDHI_TC_PROFILING -#define DEBUG_TRACES +// #define GUDHI_TC_PROFILING // #define GUDHI_TC_VERY_VERBOSE // #define GUDHI_TC_PERFORM_EXTRA_CHECKS // #define GUDHI_TC_SHOW_DETAILED_STATS_FOR_INCONSISTENCIES diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 09ebb678..2746cab9 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -29,6 +29,10 @@ if(PYTHON_PATH AND CYTHON_PATH) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-fp-model strict', ") endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + if (DEBUG_TRACES) + # For programs to be more verbose + set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DDEBUG_TRACES', ") + endif() find_package(Eigen3 3.1.0) diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/cython/alpha_complex.pyx index ed518c38..93f9b87e 100644 --- a/src/cython/cython/alpha_complex.pyx +++ b/src/cython/cython/alpha_complex.pyx @@ -38,7 +38,7 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, bool from_file) vector[double] get_point(int vertex) - void create_simplex_tree(Simplex_tree_interface_full_featured simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) # AlphaComplex python interface cdef class AlphaComplex: @@ -100,19 +100,20 @@ cdef class AlphaComplex: :param vertex: The vertex. :type vertex: int - :returns: list of float -- the point. + :rtype: list of float + :returns: the point. """ cdef vector[double] point = self.thisptr.get_point(vertex) return point - def create_simplex_tree(self, SimplexTree simplex_tree, max_alpha_square=float('inf')): - """This function creates the given simplex tree from the Delaunay - Triangulation. - - :param simplex_tree: The simplex tree to create (must be empty) - :type simplex_tree: SimplexTree + def create_simplex_tree(self, max_alpha_square=float('inf')): + """ :param max_alpha_square: The maximum alpha square threshold the simplices shall not exceed. Default is set to infinity. :type max_alpha_square: float + :returns: A simplex tree created from the Delaunay Triangulation. + :rtype: SimplexTree """ - self.thisptr.create_simplex_tree(deref(simplex_tree.thisptr), max_alpha_square) \ No newline at end of file + simplex_tree = SimplexTree() + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square) + return simplex_tree diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index cf7cbe26..06e2eb90 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -102,7 +102,8 @@ cdef class SimplexTree: def get_filtration(self): """This function returns the main simplicial complex filtration value. - :returns: float -- the simplicial complex filtration value. + :returns: The simplicial complex filtration value. + :rtype: float """ return self.thisptr.filtration() @@ -112,7 +113,8 @@ cdef class SimplexTree: :param simplex: The N-simplex, represented by a list of vertex. :type simplex: list of int. - :returns: float -- the simplicial complex filtration value. + :returns: The simplicial complex filtration value. + :rtype: float """ return self.thisptr.simplex_filtration(simplex) @@ -140,7 +142,8 @@ cdef class SimplexTree: """This function returns the number of vertices of the simplicial complex. - :returns: int -- the simplicial complex number of vertices. + :returns: The simplicial complex number of vertices. + :rtype: int """ return self.thisptr.num_vertices() @@ -148,14 +151,16 @@ cdef class SimplexTree: """This function returns the number of simplices of the simplicial complex. - :returns: int -- the simplicial complex number of simplices. + :returns: the simplicial complex number of simplices. + :rtype: int """ return self.thisptr.num_simplices() def dimension(self): """This function returns the dimension of the simplicial complex. - :returns: int -- the simplicial complex dimension. + :returns: the simplicial complex dimension. + :rtype: int """ return self.thisptr.dimension() @@ -173,7 +178,8 @@ cdef class SimplexTree: :param simplex: The N-simplex to find, represented by a list of vertex. :type simplex: list of int. - :returns: bool -- true if the simplex was found, false otherwise. + :returns: true if the simplex was found, false otherwise. + :rtype: bool """ cdef vector[int] complex for i in simplex: @@ -189,7 +195,8 @@ cdef class SimplexTree: :type simplex: list of int. :param filtration: The filtration value of the simplex. :type filtration: float. - :returns: bool -- true if the simplex was found, false otherwise. + :returns: true if the simplex was found, false otherwise. + :rtype: bool """ cdef vector[int] complex for i in simplex: @@ -201,8 +208,8 @@ cdef class SimplexTree: """This function returns the tree sorted by increasing filtration values. - :returns: list of tuples(simplex, filtration) -- the tree sorted by - increasing filtration values. + :returns: The tree sorted by increasing filtration values. + :rtype: list of tuples(simplex, filtration) """ cdef vector[pair[vector[int], double]] coface_tree \ = self.thisptr.get_filtered_tree() @@ -220,8 +227,8 @@ cdef class SimplexTree: :param dimension: The skeleton dimension value. :type dimension: int. - :returns: list of tuples(simplex, filtration) -- the skeleton tree - of a maximum dimension. + :returns: The skeleton tree of a maximum dimension. + :rtype: list of tuples(simplex, filtration) """ cdef vector[pair[vector[int], double]] coface_tree \ = self.thisptr.get_skeleton_tree(dimension) @@ -238,8 +245,8 @@ cdef class SimplexTree: :param simplex: The N-simplex, represented by a list of vertex. :type simplex: list of int. - :returns: list of tuples(simplex, filtration) -- the star tree of a - simplex. + :returns: The star tree of a simplex. + :rtype: list of tuples(simplex, filtration) """ cdef vector[int] complex for i in simplex: @@ -263,8 +270,8 @@ cdef class SimplexTree: :param codimension: The codimension. If codimension = 0, all cofaces are returned (equivalent of get_star_tree function) :type codimension: int. - :returns: list of tuples(simplex, filtration) -- the coface tree of a - simplex. + :returns: The coface tree of a simplex. + :rtype: list of tuples(simplex, filtration) """ cdef vector[int] complex for i in simplex: @@ -299,8 +306,8 @@ cdef class SimplexTree: 0.0. Sets min_persistence to -1.0 to see all values. :type min_persistence: float. - :note: list of pairs(dimension, pair(birth, death)) -- the - persistence of the simplicial complex. + :returns: The persistence of the simplicial complex. + :rtype: list of pairs(dimension, pair(birth, death)) """ if self.pcohptr != NULL: del self.pcohptr @@ -313,7 +320,8 @@ cdef class SimplexTree: def betti_numbers(self): """This function returns the Betti numbers of the simplicial complex. - :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). + :returns: The Betti numbers ([B0, B1, ..., Bn]). + :rtype: list of int :note: betti_numbers function requires persistence function to be launched first. @@ -337,8 +345,8 @@ cdef class SimplexTree: numbers (persistent death > to_value). :type to_value: float. - :returns: list of int -- The persistent Betti numbers ([B0, B1, ..., - Bn]). + :returns: The persistent Betti numbers ([B0, B1, ..., Bn]). + :rtype: list of int :note: persistent_betti_numbers function requires persistence function to be launched first. diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx index 35f1e384..f0e4eb02 100644 --- a/src/cython/cython/tangential_complex.pyx +++ b/src/cython/cython/tangential_complex.pyx @@ -37,12 +37,12 @@ cdef extern from "Tangential_complex_interface.h" namespace "Gudhi": Tangential_complex_interface(vector[vector[double]] points) # bool from_file is a workaround for cython to find the correct signature Tangential_complex_interface(string off_file, bool from_file) - vector[double] get_point(int vertex) + vector[double] get_point(unsigned vertex) unsigned number_of_vertices() unsigned number_of_simplices() unsigned number_of_inconsistent_simplices() unsigned number_of_inconsistent_stars() - void create_simplex_tree(Simplex_tree_interface_full_featured simplex_tree) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree) # TangentialComplex python interface cdef class TangentialComplex: @@ -137,11 +137,15 @@ cdef class TangentialComplex: """ return self.thisptr.number_of_inconsistent_stars() - def create_simplex_tree(self, SimplexTree simplex_tree): + def create_simplex_tree(self): """This function creates the given simplex tree from the Delaunay Triangulation. :param simplex_tree: The simplex tree to create (must be empty) :type simplex_tree: SimplexTree + :returns: A simplex tree created from the Delaunay Triangulation. + :rtype: SimplexTree """ - self.thisptr.create_simplex_tree(deref(simplex_tree.thisptr)) \ No newline at end of file + simplex_tree = SimplexTree() + self.thisptr.create_simplex_tree(simplex_tree.thisptr) + return simplex_tree diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index 5ad3a9e7..ed2a470c 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -25,14 +25,13 @@ This example builds the Delaunay triangulation from the given points, and initia import gudhi alpha_complex = gudhi.AlphaComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) - simplex_tree = gudhi.SimplexTree() - alpha_complex.create_simplex_tree(simplex_tree, max_alpha_square=60.0) + simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=60.0) result_str = 'Alpha complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) - for fitered_value in simplex_tree.get_filtered_tree(): - print(fitered_value) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) The output is: @@ -156,14 +155,13 @@ Then, it is asked to display information about the alpha complex: import gudhi alpha_complex = gudhi.AlphaComplex(off_file='alphacomplexdoc.off') - simplex_tree = gudhi.SimplexTree() - alpha_complex.create_simplex_tree(simplex_tree, max_alpha_square=59.0) + simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=59.0) result_str = 'Alpha complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) - for fitered_value in simplex_tree.get_filtered_tree(): - print(fitered_value) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) the program output is: diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index b23ad5e6..43c695bf 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -41,7 +41,6 @@ This function can display the persistence result as a diagram: import gudhi alpha_complex = gudhi.AlphaComplex(off_file='tore3D_300.off') - simplex_tree = gudhi.SimplexTree() - alpha_complex.create_simplex_tree(simplex_tree) + simplex_tree = alpha_complex.create_simplex_tree() diag = simplex_tree.persistence() gudhi.diagram_persistence(diag) diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 588de08c..33c03e34 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -111,20 +111,55 @@ itself and/or after the perturbation process. Simple example -------------- -This example builds the Tangential complex of point set. Note that the -dimension of the kernel here is dynamic, which is slower, but more flexible: -the intrinsic and ambient dimensions does not have to be known at compile-time. +This example builds the Tangential complex of point set. -testcode:: +.. testcode:: - import gudhi - tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + import gudhi + tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + result_str = 'Tangential contains ' + repr(tc.num_simplices()) + \ + ' simplices - ' + repr(tc.num_vertices()) + ' vertices.' + print(result_str) -The output is: + st = tc.create_simplex_tree() + result_str = 'Simplex tree is of dimension ' + repr(st.dimension()) + \ + ' - ' + repr(st.num_simplices()) + ' simplices - ' + \ + repr(st.num_vertices()) + ' vertices.' + print(result_str) + for filtered_value in st.get_filtered_tree(): + print(filtered_value) -testoutput:: +The output is: - Tangential complex is of dimension 2 - 25 simplices - 7 vertices. +.. testoutput:: + + Tangential contains 18 simplices - 7 vertices. + Simplex tree is of dimension 2 - 25 simplices - 7 vertices. + ([0], 0.0) + ([1], 0.0) + ([0, 1], 0.0) + ([2], 0.0) + ([0, 2], 0.0) + ([1, 2], 0.0) + ([0, 1, 2], 0.0) + ([3], 0.0) + ([1, 3], 0.0) + ([2, 3], 0.0) + ([1, 2, 3], 0.0) + ([4], 0.0) + ([0, 4], 0.0) + ([2, 4], 0.0) + ([0, 2, 4], 0.0) + ([5], 0.0) + ([4, 5], 0.0) + ([6], 0.0) + ([2, 6], 0.0) + ([3, 6], 0.0) + ([2, 3, 6], 0.0) + ([4, 6], 0.0) + ([2, 4, 6], 0.0) + ([5, 6], 0.0) + ([4, 5, 6], 0.0) Example with perturbation diff --git a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py index 40d06f93..6cdd5506 100755 --- a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py @@ -53,8 +53,7 @@ with open(args.file, 'r') as f: print(message) alpha_complex = gudhi.AlphaComplex(off_file=args.file) - simplex_tree = gudhi.SimplexTree() - alpha_complex.create_simplex_tree(simplex_tree, max_alpha_square=args.max_alpha_square) + simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square) message = "Number of simplices=" + repr(simplex_tree.num_simplices()) print(message) diff --git a/src/cython/example/alpha_complex_from_points_example.py b/src/cython/example/alpha_complex_from_points_example.py index 45319f7f..ae21c711 100755 --- a/src/cython/example/alpha_complex_from_points_example.py +++ b/src/cython/example/alpha_complex_from_points_example.py @@ -31,8 +31,7 @@ __license__ = "GPL v3" print("#####################################################################") print("AlphaComplex creation from points") alpha_complex = AlphaComplex(points=[[0, 0], [1, 0], [0, 1], [1, 1]]) -simplex_tree = SimplexTree() -alpha_complex.create_simplex_tree(simplex_tree, max_alpha_square=60.0) +simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=60.0) if simplex_tree.find([0, 1]): print("[0, 1] Found !!") diff --git a/src/cython/include/Alpha_complex_interface.h b/src/cython/include/Alpha_complex_interface.h index 15384206..81761c77 100644 --- a/src/cython/include/Alpha_complex_interface.h +++ b/src/cython/include/Alpha_complex_interface.h @@ -69,9 +69,9 @@ class Alpha_complex_interface { return vd; } - void create_simplex_tree(Simplex_tree_interface<>& simplex_tree, double max_alpha_square) { - alpha_complex_->create_complex(simplex_tree, max_alpha_square); - simplex_tree.initialize_filtration(); + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square) { + alpha_complex_->create_complex(*simplex_tree, max_alpha_square); + simplex_tree->initialize_filtration(); } private: diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index 49d66476..c7fce557 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -73,14 +73,12 @@ class Tangential_complex_interface { num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices(); } - std::vector get_point(int vh) { + std::vector get_point(unsigned vh) { std::vector vd; - try { + if (vh < tangential_complex_->number_of_vertices()) { Point_d ph = tangential_complex_->get_point(vh); for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++) vd.push_back(*coord); - } catch (std::out_of_range outofrange) { - // std::out_of_range is thrown in case not found. Other exceptions must be re-thrown } return vd; } @@ -101,9 +99,11 @@ class Tangential_complex_interface { return num_inconsistencies_.num_inconsistent_stars; } - void create_simplex_tree(Simplex_tree<>& simplex_tree) { - tangential_complex_->create_complex>(simplex_tree); - simplex_tree.initialize_filtration(); + void create_simplex_tree(Simplex_tree<>* simplex_tree) { + int max_dim = tangential_complex_->create_complex>(*simplex_tree); + // FIXME + simplex_tree->set_dimension(max_dim); + simplex_tree->initialize_filtration(); } private: diff --git a/src/cython/test/test_alpha_complex.py b/src/cython/test/test_alpha_complex.py index 3731ccda..b08ac0d7 100755 --- a/src/cython/test/test_alpha_complex.py +++ b/src/cython/test/test_alpha_complex.py @@ -36,8 +36,7 @@ def test_infinite_alpha(): alpha_complex = AlphaComplex(points=point_list) assert alpha_complex.__is_defined() == True - simplex_tree = SimplexTree() - alpha_complex.create_simplex_tree(simplex_tree) + simplex_tree = alpha_complex.create_simplex_tree() assert simplex_tree.__is_persistence_defined() == False assert simplex_tree.num_simplices() == 11 @@ -65,8 +64,7 @@ def test_filtered_alpha(): point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] filtered_alpha = AlphaComplex(points=point_list) - simplex_tree = SimplexTree() - filtered_alpha.create_simplex_tree(simplex_tree, max_alpha_square=0.25) + simplex_tree = filtered_alpha.create_simplex_tree(max_alpha_square=0.25) assert simplex_tree.num_simplices() == 8 assert simplex_tree.num_vertices() == 4 -- cgit v1.2.3 From d7d59f1e4245af3595c8eafd0abc0abdc4b5805d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 30 Nov 2016 10:33:56 +0000 Subject: Doc, examples and tests updates for tangential git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1805 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 56d080f79a7a0c3b6eb3ed38b376e899cb17c8f9 --- src/cython/cython/simplex_tree.pyx | 7 ++- src/cython/cython/tangential_complex.pyx | 12 ++++ src/cython/doc/tangential_complex_user.rst | 23 ++++++-- ...ex_diagram_persistence_from_off_file_example.py | 3 +- ...complex_plain_homology_from_off_file_example.py | 66 ++++++++++++++++++++++ src/cython/include/Tangential_complex_interface.h | 9 ++- src/cython/test/test_tangential_complex.py | 56 ++++++++++++++++++ 7 files changed, 164 insertions(+), 12 deletions(-) create mode 100755 src/cython/example/tangential_complex_plain_homology_from_off_file_example.py create mode 100755 src/cython/test/test_tangential_complex.py (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 06e2eb90..8f909398 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -1,6 +1,7 @@ from cython cimport numeric from libcpp.vector cimport vector from libcpp.utility cimport pair +from libcpp cimport bool """This file is part of the Gudhi Library. The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ @@ -54,7 +55,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface>": - Simplex_tree_persistence_interface(Simplex_tree_interface_full_featured * st) + Simplex_tree_persistence_interface(Simplex_tree_interface_full_featured * st, bool persistence_dim_max) vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence) vector[int] betti_numbers() vector[int] persistent_betti_numbers(double from_value, double to_value) @@ -295,7 +296,7 @@ cdef class SimplexTree: """ self.thisptr.remove_maximal_simplex(simplex) - def persistence(self, homology_coeff_field=11, min_persistence=0): + def persistence(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False): """This function returns the persistence of the simplicial complex. :param homology_coeff_field: The homology coefficient field. Must be a @@ -311,7 +312,7 @@ cdef class SimplexTree: """ if self.pcohptr != NULL: del self.pcohptr - self.pcohptr = new Simplex_tree_persistence_interface(self.thisptr) + self.pcohptr = new Simplex_tree_persistence_interface(self.thisptr, persistence_dim_max) cdef vector[pair[int, pair[double, double]]] persistence_result if self.pcohptr != NULL: persistence_result = self.pcohptr.get_persistence(homology_coeff_field, min_persistence) diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx index f0e4eb02..5a7ebd1a 100644 --- a/src/cython/cython/tangential_complex.pyx +++ b/src/cython/cython/tangential_complex.pyx @@ -43,6 +43,7 @@ cdef extern from "Tangential_complex_interface.h" namespace "Gudhi": unsigned number_of_inconsistent_simplices() unsigned number_of_inconsistent_stars() void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree) + void fix_inconsistencies_using_perturbation(double max_perturb, double time_limit) # TangentialComplex python interface cdef class TangentialComplex: @@ -149,3 +150,14 @@ cdef class TangentialComplex: simplex_tree = SimplexTree() self.thisptr.create_simplex_tree(simplex_tree.thisptr) return simplex_tree + + def fix_inconsistencies_using_perturbation(self, max_perturb, time_limit=-1.0): + """Attempts to fix inconsistencies by perturbing the point positions. + :param max_perturb: Maximum length of the translations used by the + perturbation. + :type max_perturb: double + :param time_limit: Time limit in seconds. If -1, no time limit is set. + :type time_limit: double + """ + self.thisptr.fix_inconsistencies_using_perturbation(max_perturb, + time_limit) diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 33c03e34..30c97b8f 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -111,12 +111,12 @@ itself and/or after the perturbation process. Simple example -------------- -This example builds the Tangential complex of point set. +This example builds the Tangential complex of point set read in an OFF file. .. testcode:: import gudhi - tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + tc = gudhi.TangentialComplex(off_file='alphacomplexdoc.off') result_str = 'Tangential contains ' + repr(tc.num_simplices()) + \ ' simplices - ' + repr(tc.num_vertices()) + ' vertices.' print(result_str) @@ -169,11 +169,24 @@ This example builds the Tangential complex of a point set, then tries to solve inconsistencies by perturbing the positions of points involved in inconsistent simplices. -testcode:: +.. testcode:: import gudhi - tc = gudhi.TangentialComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]) + tc = gudhi.TangentialComplex(points=[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) + result_str = 'Tangential contains ' + repr(tc.num_vertices()) + ' vertices.' + print(result_str) + + if tc.num_inconsistent_simplices() > 0: + print('Tangential contains inconsistencies.') + + tc.fix_inconsistencies_using_perturbation(10, 60) + if tc.num_inconsistent_simplices() == 0: + print('Inconsistencies has been fixed.') The output is: -testoutput:: +.. testoutput:: + + Tangential contains 4 vertices. + Tangential contains inconsistencies. + Inconsistencies has been fixed. diff --git a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py index 6cdd5506..ae03aa67 100755 --- a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py @@ -35,8 +35,7 @@ parser = argparse.ArgumentParser(description='AlphaComplex creation from ' 'example/alpha_complex_diagram_persistence_from_off_file_example.py ' '-f ../data/points/tore3D_300.off -a 0.6' '- Constructs a alpha complex with the ' - 'points from the given file. File format ' - 'is X1, X2, ..., Xn') + 'points from the given OFF file.') parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, default=0.5) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') diff --git a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py new file mode 100755 index 00000000..be4c40be --- /dev/null +++ b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +import gudhi +import argparse + +"""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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +parser = argparse.ArgumentParser(description='TangentialComplex creation from ' + 'points read in a OFF file.', + epilog='Example: ' + 'example/tangential_complex_plain_homology_from_off_file_example.py ' + '-f ../data/points/tore3D_300.off' + '- Constructs a tangential complex with the ' + 'points from the given OFF file') +parser.add_argument("-f", "--file", type=str, required=True) +parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') + +args = parser.parse_args() + +with open(args.file, 'r') as f: + first_line = f.readline() + if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): + print("#####################################################################") + print("TangentialComplex creation from points read in a OFF file") + + tc = gudhi.TangentialComplex(off_file=args.file) + st = tc.create_simplex_tree() + + message = "Number of simplices=" + repr(st.num_simplices()) + print(message) + + diag = st.persistence(persistence_dim_max = True) + + print("betti_numbers()=") + print(st.betti_numbers()) + + if args.no_diagram == False: + gudhi.diagram_persistence(diag) + else: + print(args.file, "is not a valid OFF file") + + f.close() diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index c7fce557..9da32757 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -53,7 +53,7 @@ class Tangential_complex_interface { Dynamic_kernel k; unsigned intrisic_dim = 0; if (points.size() > 0) - intrisic_dim = points[0].size(); + intrisic_dim = points[0].size() - 1; tangential_complex_ = new TC(points, intrisic_dim, k); tangential_complex_->compute_tangential_complex(); @@ -66,7 +66,7 @@ class Tangential_complex_interface { unsigned intrisic_dim = 0; std::vector points = off_reader.get_point_cloud(); if (points.size() > 0) - intrisic_dim = points[0].size(); + intrisic_dim = points[0].size() - 1; tangential_complex_ = new TC(points, intrisic_dim, k); tangential_complex_->compute_tangential_complex(); @@ -99,6 +99,11 @@ class Tangential_complex_interface { return num_inconsistencies_.num_inconsistent_stars; } + void fix_inconsistencies_using_perturbation(double max_perturb, double time_limit) { + tangential_complex_->fix_inconsistencies_using_perturbation(max_perturb, time_limit); + num_inconsistencies_ = tangential_complex_->number_of_inconsistent_simplices(); + } + void create_simplex_tree(Simplex_tree<>* simplex_tree) { int max_dim = tangential_complex_->create_complex>(*simplex_tree); // FIXME diff --git a/src/cython/test/test_tangential_complex.py b/src/cython/test/test_tangential_complex.py new file mode 100755 index 00000000..8e1b5c51 --- /dev/null +++ b/src/cython/test/test_tangential_complex.py @@ -0,0 +1,56 @@ +from gudhi import TangentialComplex, SimplexTree + +"""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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + + +def test_tangential(): + point_list = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]] + tc = TangentialComplex(points=point_list) + assert tc.__is_defined() == True + assert tc.num_vertices() == 4 + + st = tc.create_simplex_tree() + assert st.__is_defined() == True + assert st.__is_persistence_defined() == False + + assert st.num_simplices() == 13 + assert st.num_vertices() == 4 + + assert st.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([0, 1], 0.0), ([2], 0.0), ([0, 2], 0.0), + ([1, 2], 0.0), ([3], 0.0), ([0, 3], 0.0), ([1, 3], 0.0), + ([0, 1, 3], 0.0), ([2, 3], 0.0), ([0, 2, 3], 0.0), + ([1, 2, 3], 0.0)] + assert st.get_coface_tree([0], 1) == \ + [([0, 1], 0.0), ([0, 2], 0.0), ([0, 3], 0.0)] + + assert point_list[0] == tc.get_point(0) + assert point_list[1] == tc.get_point(1) + assert point_list[2] == tc.get_point(2) + assert point_list[3] == tc.get_point(3) + assert tc.get_point(4) == [] + assert tc.get_point(125) == [] -- cgit v1.2.3 From e5345d29ca69d318f8c9b39cab21d79944ed69bb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 30 Jan 2017 15:34:00 +0000 Subject: Biblio fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2030 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1b2cbbd0486b14d27230287cd97582285258eb74 --- src/cython/doc/alpha_complex_user.rst | 2 ++ src/cython/doc/bottleneck_distance_ref.rst | 2 +- src/cython/doc/cubical_complex_user.rst | 2 ++ src/cython/doc/how_to_cite_cgal.rst | 7 +++++++ src/cython/doc/index.rst | 3 +++ src/cython/doc/persistent_cohomology_user.rst | 2 ++ src/cython/doc/tangential_complex_user.rst | 2 ++ 7 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/cython/doc/how_to_cite_cgal.rst (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index ed2a470c..1ca96b6e 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -191,3 +191,5 @@ the program output is: ([2, 6], 36.5) ([2, 3, 6], 36.5) ([2, 4, 6], 37.24489795918368) + +.. :include: how_to_cite_cgal.rst diff --git a/src/cython/doc/bottleneck_distance_ref.rst b/src/cython/doc/bottleneck_distance_ref.rst index 7f816cd6..91a2ab05 100644 --- a/src/cython/doc/bottleneck_distance_ref.rst +++ b/src/cython/doc/bottleneck_distance_ref.rst @@ -2,4 +2,4 @@ Bottleneck reference manual =========================== -.. automethod:: gudhi.bottleneck_distance +.. autofunction:: gudhi.bottleneck_distance diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 2cd85c0a..16712de5 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -148,3 +148,5 @@ Examples. --------- End user programs are available in cython/example/ folder. + +.. include:: biblio.rst diff --git a/src/cython/doc/how_to_cite_cgal.rst b/src/cython/doc/how_to_cite_cgal.rst new file mode 100644 index 00000000..192e0562 --- /dev/null +++ b/src/cython/doc/how_to_cite_cgal.rst @@ -0,0 +1,7 @@ +============== +CGAL citations +============== + +.. bibliography:: how_to_cite_cgal.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index de90cf7c..bd138fd5 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -11,6 +11,7 @@ GUDHI's documentation Introduction ************ +:doc:`biblio` The Gudhi library (Geometry Understanding in Higher Dimensions) is a generic open source C++ library for Computational Topology and Topological Data @@ -76,3 +77,5 @@ Persistence graphical tools =========================== .. include:: persistence_graphical_tools_sum.rst + +.. include:: biblio.rst diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index ca936754..1479fb1e 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -99,3 +99,5 @@ We provide several example files: run these examples with -h for details on thei .. todo:: examples for persistence + +.. include:: biblio.rst diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 1ad08bd6..7b6c9e79 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -179,3 +179,5 @@ The output is: Tangential contains 4 vertices. Inconsistencies has been fixed. + +.. include:: biblio.rst -- cgit v1.2.3 From 0921d31dec497b21a3b2805790ef295e90566e3d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 2 Feb 2017 07:58:53 +0000 Subject: Change doc html theme. Change tables git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2047 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: aaa29b8f610d506efc3762ad17c4fd768e74d399 --- src/cython/CMakeLists.txt | 6 +- src/cython/cython/rips_complex.pyx | 20 +--- src/cython/doc/alpha_complex_sum.rst | 43 ++++--- src/cython/doc/alpha_complex_user.rst | 16 ++- src/cython/doc/biblio.rst | 3 +- src/cython/doc/bottleneck_distance_sum.rst | 28 ++--- src/cython/doc/bottleneck_distance_user.rst | 2 +- src/cython/doc/conf.py | 2 +- src/cython/doc/cubical_complex_sum.rst | 25 ++-- src/cython/doc/cubical_complex_user.rst | 14 ++- src/cython/doc/index.rst | 6 +- src/cython/doc/persistence_graphical_tools_sum.rst | 23 ++-- src/cython/doc/persistent_cohomology_sum.rst | 50 ++++---- src/cython/doc/rips_complex_ref.rst | 10 ++ src/cython/doc/rips_complex_sum.rst | 17 +++ src/cython/doc/rips_complex_user.rst | 133 +++++++++++++++++++++ src/cython/doc/simplex_tree_sum.rst | 25 ++-- src/cython/doc/tangential_complex_sum.rst | 29 +++-- src/cython/doc/tangential_complex_user.rst | 7 ++ src/cython/doc/witness_complex_sum.rst | 48 ++++---- 20 files changed, 338 insertions(+), 169 deletions(-) create mode 100644 src/cython/doc/rips_complex_ref.rst create mode 100644 src/cython/doc/rips_complex_sum.rst create mode 100644 src/cython/doc/rips_complex_user.rst (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 6c49c800..72be7b30 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -101,7 +101,7 @@ if(PYTHON_PATH AND CYTHON_PATH) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND python "${CMAKE_CURRENT_BINARY_DIR}/cythonize_gudhi.py" "build_ext" "--inplace") - add_custom_target(cythonize_gudhi ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" + add_custom_target(cython ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" COMMENT "Do not forget to add ${CMAKE_CURRENT_BINARY_DIR}/gudhi.so to your PYTHONPATH before using examples") # Unitary tests are available through py.test @@ -135,11 +135,11 @@ if(PYTHON_PATH AND CYTHON_PATH) file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") if (UNIX) - add_custom_target(html + add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc COMMAND make html && make doctest) else (UNIX) - add_custom_target(html + add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc COMMAND make.bat html) endif (UNIX) diff --git a/src/cython/cython/rips_complex.pyx b/src/cython/cython/rips_complex.pyx index 2e739ac3..7e04ca4b 100644 --- a/src/cython/cython/rips_complex.pyx +++ b/src/cython/cython/rips_complex.pyx @@ -40,22 +40,10 @@ cdef extern from "Rips_complex_interface.h" namespace "Gudhi": # RipsComplex python interface cdef class RipsComplex: - """RipsComplex is a simplicial complex constructed from the finite cells - of a Delaunay Triangulation. - - The filtration value of each simplex is computed as the square of the - circumradius of the simplex if the circumsphere is empty (the simplex is - then said to be Gabriel), and as the minimum of the filtration values of - the codimension 1 cofaces that make it not Gabriel otherwise. - - All simplices that have a filtration value strictly greater than a given - alpha squared value are not inserted into the complex. - - .. note:: - - When Rips_complex is constructed with an infinite value of alpha, the - complex is a Delaunay complex. - + """The data structure is a one skeleton graph, or Rips graph, containing + edges when the edge length is less or equal to a given threshold. Edge + length is computed from a user given point cloud with a given distance + function, or a distance matrix. """ cdef Rips_complex_interface * thisptr diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index af6c087f..0ccbcc21 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -1,23 +1,22 @@ -===================================== ===================================== ===================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.7.0 Eigen3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.7.0 Eigen3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Alpha_complex is a simplicial complex constructed from the finite | -| img/alpha_complex_representation.png | cells of a Delaunay Triangulation. | -| | | -| | The filtration value of each simplex is computed as the square of the| -| | circumradius of the simplex if the circumsphere is empty (the simplex| -| | is then said to be Gabriel), and as the minimum of the filtration | -| | values of the codimension 1 cofaces that make it not Gabriel | -| | otherwise. All simplices that have a filtration value strictly | -| | greater than a given alpha squared value are not inserted into the | -| | complex. | -| | | -| | This package requires having CGAL version 4.7 or higher (4.8.1 is | -| | advised for better perfomances). | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | +| img/alpha_complex_representation.png | cells of a Delaunay Triangulation. | +| :alt: Alpha complex representation | | +| :figclass: align-center | The filtration value of each simplex is computed as the square of the | +| | circumradius of the simplex if the circumsphere is empty (the simplex | +| Alpha complex representation | is then said to be Gabriel), and as the minimum of the filtration | +| | values of the codimension 1 cofaces that make it not Gabriel | +| | otherwise. All simplices that have a filtration value strictly | +| | greater than a given alpha squared value are not inserted into the | +| | complex. | +| | | +| | This package requires having CGAL version 4.7 or higher (4.8.1 is | +| | advised for better perfomances). | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index 1ca96b6e..f1c57248 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -74,11 +74,13 @@ Data structure In order to build the alpha complex, first, a Simplex tree is built from the cells of a Delaunay Triangulation. (The filtration value is set to NaN, which stands for unknown value): -.. image:: +.. figure:: img/alpha_complex_doc.png - :align: center + :figclass: align-center :alt: Simplex tree structure construction example + Simplex tree structure construction example + Filtration value computation algorithm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,9 +89,9 @@ Filtration value computation algorithm **if** filtration(:math:`\sigma`) is NaN **then** filtration(:math:`\sigma`) = :math:`\alpha^2(\sigma)` **end if** - + *//propagate alpha filtration value* - + **for all** :math:`\tau` face of :math:`\sigma` **if** filtration(:math:`\tau`) is not NaN **then** filtration(:math:`\tau`) = filtration(:math:`\sigma`) @@ -109,11 +111,13 @@ From the example above, it means the algorithm looks into each triangle ([0,1,2] computes the filtration value of the triangle, and then propagates the filtration value as described here: -.. image:: +.. figure:: img/alpha_complex_doc_420.png - :align: center + :figclass: align-center :alt: Filtration value propagation example + Filtration value propagation example + Dimension 1 ^^^^^^^^^^^ diff --git a/src/cython/doc/biblio.rst b/src/cython/doc/biblio.rst index b8e733ed..3995e9c0 100644 --- a/src/cython/doc/biblio.rst +++ b/src/cython/doc/biblio.rst @@ -1,6 +1,5 @@ -============ Bibliography -============ +************ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/doc/bottleneck_distance_sum.rst b/src/cython/doc/bottleneck_distance_sum.rst index 6cffa122..6fec9b7e 100644 --- a/src/cython/doc/bottleneck_distance_sum.rst +++ b/src/cython/doc/bottleneck_distance_sum.rst @@ -1,15 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Francois Godi :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.8.0 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: François Godi :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Bottleneck distance measures the similarity between two persistence | -| img/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | -| | perfect matching between the points of the two diagrams (+ all the | -| | diagonal points) such that any couple of matched points are at | -| | distance at most b. | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`bottleneck_distance_user` | :doc:`bottleneck_distance_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | Bottleneck distance measures the similarity between two persistence | +| img/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | +| :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | +| | diagonal points) such that any couple of matched points are at | +| Bottleneck distance is the length of | distance at most b. | +| the longest edge | | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`bottleneck_distance_user` | :doc:`bottleneck_distance_ref` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/bottleneck_distance_user.rst b/src/cython/doc/bottleneck_distance_user.rst index 08c6e451..3bc170f4 100644 --- a/src/cython/doc/bottleneck_distance_user.rst +++ b/src/cython/doc/bottleneck_distance_user.rst @@ -8,7 +8,7 @@ Definition Function -------- -.. automethod:: gudhi.bottleneck_distance +.. autofunction:: gudhi.bottleneck_distance Basic example diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index 8b42ce37..680377b3 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -114,7 +114,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = 'bizstyle' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/src/cython/doc/cubical_complex_sum.rst b/src/cython/doc/cubical_complex_sum.rst index 98e23849..399c2357 100644 --- a/src/cython/doc/cubical_complex_sum.rst +++ b/src/cython/doc/cubical_complex_sum.rst @@ -1,12 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Pawel Dlotko :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Pawel Dlotko :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The cubical complex is an example of a structured complex useful in | -| img/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | -| | analysis. | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | The cubical complex is an example of a structured complex useful in | +| img/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | +| :alt: Cubical complex representation | analysis. | +| :figclass: align-center | | +| | | +| Cubical complex representation | | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | +| | * :doc:`periodic_cubical_complex_ref` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 16712de5..809aaddf 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -5,7 +5,7 @@ Definition ---------- ===================================== ===================================== ===================================== -:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 1.4.0 :Copyright: GPL v3 +:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 1.3.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== +---------------------------------------------+----------------------------------------------------------------------+ @@ -59,10 +59,12 @@ of filtration. This, together with dimension of :math:`\mathcal{K}` and the size directions, allows to determine, dimension, neighborhood, boundary and coboundary of every cube :math:`C \in \mathcal{K}`. -.. image:: +.. figure:: img/Cubical_complex_representation.png - :align: center :alt: Cubical complex. + :figclass: align-center + + Cubical complex. Note that the cubical complex in the figure above is, in a natural way, a product of one dimensional cubical complexes in :math:`\mathbb{R}`. The number of all cubes in each direction is equal :math:`2n+1`, where :math:`n` is @@ -85,10 +87,12 @@ bitmap (2 in the example below). Next d lines are the numbers of top dimensional in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8 20 4 7 6 5 in the example below). -.. image:: +.. figure:: img/exampleBitmap.png - :align: center :alt: Example of a input data. + :figclass: align-center + + Example of a input data. The input file for the following complex is: diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index bd138fd5..236ef3a4 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -11,7 +11,6 @@ GUDHI's documentation Introduction ************ -:doc:`biblio` The Gudhi library (Geometry Understanding in Higher Dimensions) is a generic open source C++ library for Computational Topology and Topological Data @@ -44,6 +43,11 @@ Cubical complex .. include:: cubical_complex_sum.rst +Rips complex +============ + +.. include:: rips_complex_sum.rst + Simplex tree ============ diff --git a/src/cython/doc/persistence_graphical_tools_sum.rst b/src/cython/doc/persistence_graphical_tools_sum.rst index a4ee4398..d602daa7 100644 --- a/src/cython/doc/persistence_graphical_tools_sum.rst +++ b/src/cython/doc/persistence_graphical_tools_sum.rst @@ -1,13 +1,12 @@ -===================================== ===================================== ===================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: Matplotlib Numpy -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: Matplotlib Numpy +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | These graphical tools comes on top of persistence results and allows | -| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | -| | | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | These graphical tools comes on top of persistence results and allows | +| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | +| | | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_sum.rst b/src/cython/doc/persistent_cohomology_sum.rst index cf3029fc..5d059b00 100644 --- a/src/cython/doc/persistent_cohomology_sum.rst +++ b/src/cython/doc/persistent_cohomology_sum.rst @@ -1,25 +1,27 @@ -===================================== ===================================== ===================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The theory of homology consists in attaching to a topological space | -| img/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | -| | features like connected components, holes, cavities, etc. Persistent | -| | homology studies the evolution -- birth, life and death -- of these | -| | features when the topological space is changing. Consequently, the | -| | theory is essentially composed of three elements: topological spaces,| -| | their homology groups and an evolution scheme. | -| | | -| | Computation of persistent cohomology using the algorithm of | -| | :cite:`DBLP:journals/dcg/SilvaMV11` and | -| | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | -| | Annotation Matrix implementation of | -| | :cite:`DBLP:conf/esa/BoissonnatDM13`. | -| | | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | -| | feature for reference: | -| | | -| | * :doc:`simplex_tree_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | The theory of homology consists in attaching to a topological space | +| img/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | +| :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | +| | homology studies the evolution -- birth, life and death -- of these | +| Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | +| Torus | theory is essentially composed of three elements: topological spaces, | +| | their homology groups and an evolution scheme. | +| | | +| | Computation of persistent cohomology using the algorithm of | +| | :cite:`DBLP:journals/dcg/SilvaMV11` and | +| | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | +| | Annotation Matrix implementation of | +| | :cite:`DBLP:conf/esa/BoissonnatDM13`. | +| | | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | +| | feature for reference: | +| | | +| | * :doc:`simplex_tree_ref` | +| | * :doc:`cubical_complex_ref` | +| | * :doc:`periodic_cubical_complex_ref` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_ref.rst b/src/cython/doc/rips_complex_ref.rst new file mode 100644 index 00000000..b17dc4e0 --- /dev/null +++ b/src/cython/doc/rips_complex_ref.rst @@ -0,0 +1,10 @@ +============================= +Rips complex reference manual +============================= + +.. autoclass:: gudhi.RipsComplex + :members: + :undoc-members: + :show-inheritance: + + .. automethod:: gudhi.RipsComplex.__init__ diff --git a/src/cython/doc/rips_complex_sum.rst b/src/cython/doc/rips_complex_sum.rst new file mode 100644 index 00000000..ad57e54e --- /dev/null +++ b/src/cython/doc/rips_complex_sum.rst @@ -0,0 +1,17 @@ +================================================================= =================================== =================================== +:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Rips_complex is a simplicial complex constructed from a one skeleton | +| img/rips_complex_representation.png | graph. | +| :figclass: align-center | | +| | The filtration value of each edge is computed from a user-given | +| Rips complex representation | distance function and is inserted until a user-given threshold | +| | value. | +| | | +| | This complex can be built from a point cloud and a distance function, | +| | or from a distance matrix. | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst new file mode 100644 index 00000000..be9481de --- /dev/null +++ b/src/cython/doc/rips_complex_user.rst @@ -0,0 +1,133 @@ +========================= +Rips complex user manual +========================= +Definition +---------- + +======================================================= ===================================== ===================================== +:Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +======================================================= ===================================== ===================================== + ++-------------------------------------------+----------------------------------------------------------------------+ +| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | ++-------------------------------------------+----------------------------------------------------------------------+ + +`Rips complex `_ is a one skeleton graph that allows to +construct a simplicial complex from it. The input can be a point cloud with a given distance function, or a distance +matrix. + +The filtration value of each edge is computed from a user-given distance function, or directly from the distance +matrix. + +All edges that have a filtration value strictly greater than a given threshold value are not inserted into the complex. + +When creating a simplicial complex from this one skeleton graph, Rips inserts the one skeleton graph into the data +structure, and then expands the simplicial complex when required. + +Vertex name correspond to the index of the point in the given range (aka. the point cloud). + +.. figure:: + img/rips_complex_representation.png + :align: center + + Rips-complex one skeleton graph representation + +On this example, as edges (4,5), (4,6) and (5,6) are in the complex, simplex (4,5,6) is added with the filtration value +set with :math:`max(filtration(4,5), filtration(4,6), filtration(5,6))`. And so on for simplex (0,1,2,3). + +If the Rips_complex interfaces are not detailed enough for your need, please refer to rips_persistence_step_by_step.cpp +example, where the graph construction over the Simplex_tree is more detailed. + +Point cloud and distance function +--------------------------------- + +Example from a point cloud and a distance function +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This example builds the one skeleton graph from the given points, threshold value, and distance function. Then it +creates a :doc:`Simplex_tree ` with it. + +Then, it is asked to display information about the simplicial complex. + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]], + max_edge_length=12.0) + + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' + print(result_str) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) + +The output is: + +.. testoutput:: + + Rips complex is of dimension 1 - 18 simplices - 7 vertices. + ([0], 0.0) + ([1], 0.0) + ([2], 0.0) + ([3], 0.0) + ([4], 0.0) + ([5], 0.0) + ([6], 0.0) + ([2, 3], 5.0) + ([4, 5], 5.385164807134504) + ([0, 2], 5.830951894845301) + ([0, 1], 6.082762530298219) + ([1, 3], 6.324555320336759) + ([1, 2], 6.708203932499369) + ([5, 6], 7.280109889280518) + ([2, 4], 8.94427190999916) + ([0, 3], 9.433981132056603) + ([4, 6], 9.486832980505138) + ([3, 6], 11.0) + +Example from OFF file +^^^^^^^^^^^^^^^^^^^^^ + +This example builds the :doc:`Rips_complex ` from the given points in an OFF file, threshold value, +and distance function. Then it creates a :doc:`Simplex_tree ` with it. + +Then, it is asked to display information about the Rips complex. + + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(off_file='alphacomplexdoc.off', max_edge_length=12.0) + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' + print(result_str) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) + +the program output is: + +.. testoutput:: + + Rips complex is of dimension 1 - 18 simplices - 7 vertices. + ([0], 0.0) + ([1], 0.0) + ([2], 0.0) + ([3], 0.0) + ([4], 0.0) + ([5], 0.0) + ([6], 0.0) + ([2, 3], 5.0) + ([4, 5], 5.385164807134504) + ([0, 2], 5.830951894845301) + ([0, 1], 6.082762530298219) + ([1, 3], 6.324555320336759) + ([1, 2], 6.708203932499369) + ([5, 6], 7.280109889280518) + ([2, 4], 8.94427190999916) + ([0, 3], 9.433981132056603) + ([4, 6], 9.486832980505138) + ([3, 6], 11.0) diff --git a/src/cython/doc/simplex_tree_sum.rst b/src/cython/doc/simplex_tree_sum.rst index 0f34888a..b79cf4fd 100644 --- a/src/cython/doc/simplex_tree_sum.rst +++ b/src/cython/doc/simplex_tree_sum.rst @@ -1,13 +1,14 @@ -===================================== ===================================== ===================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The simplex tree is an efficient and flexible data structure for | -| img/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | -| | | -| | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica` | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | The simplex tree is an efficient and flexible data structure for | +| img/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | +| :alt: Simplex tree representation | | +| :figclass: align-center | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica` | +| Simplex tree representation | | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/tangential_complex_sum.rst b/src/cython/doc/tangential_complex_sum.rst index 4e358a7b..2b05bc10 100644 --- a/src/cython/doc/tangential_complex_sum.rst +++ b/src/cython/doc/tangential_complex_sum.rst @@ -1,16 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Clément Jamin :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.8.0 Eigen3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Jamin :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 Eigen3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | A Tangential Delaunay complex is a simplicial complex designed to | -| img/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | -| | dimensional Euclidean space. The input is a point sample coming from | -| | an unknown manifold. The running time depends only linearly on the | -| | extrinsic dimension :math:`d` and exponentially on the intrinsic | -| | dimension :math:`k`. | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | +| img/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | +| :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | +| | an unknown manifold. The running time depends only linearly on the | +| **Tangential complex representation** | extrinsic dimension :math:`d` and exponentially on the intrinsic | +| | dimension :math:`k`. | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 7b6c9e79..2679528c 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -26,6 +26,7 @@ example, with :math:`k = 1` and :math:`d = 2`. The input data is 4 points .. figure:: img/tc_example_01.png :alt: The input :figclass: align-center + The input For each point :math:`p`, estimate its tangent subspace :math:`T_p` (e.g. @@ -34,8 +35,10 @@ using PCA). .. figure:: img/tc_example_02.png :alt: The estimated normals :figclass: align-center + The estimated normals + Let us add the Voronoi diagram of the points in orange. For each point :math:`p`, construct its star in the Delaunay triangulation of :math:`P` restricted to :math:`T_p`. @@ -43,6 +46,7 @@ restricted to :math:`T_p`. .. figure:: img/tc_example_03.png :alt: The Voronoi diagram :figclass: align-center + The Voronoi diagram The Tangential Delaunay complex is the union of those stars. @@ -62,6 +66,7 @@ Let us take the same example. .. figure:: img/tc_example_07_before.png :alt: Before :figclass: align-center + Before Let us slightly move the tangent subspace :math:`T_q` @@ -69,6 +74,7 @@ Let us slightly move the tangent subspace :math:`T_q` .. figure:: img/tc_example_07_after.png :alt: After :figclass: align-center + After Now, the star of :math:`Q` contains :math:`QP`, but the star of :math:`P` does @@ -77,6 +83,7 @@ not contain :math:`QP`. We have an inconsistency. .. figure:: img/tc_example_08.png :alt: After :figclass: align-center + After One way to solve inconsistencies is to randomly perturb the positions of the diff --git a/src/cython/doc/witness_complex_sum.rst b/src/cython/doc/witness_complex_sum.rst index 005a5a41..22ef36ea 100644 --- a/src/cython/doc/witness_complex_sum.rst +++ b/src/cython/doc/witness_complex_sum.rst @@ -1,25 +1,25 @@ -===================================== ===================================== ===================================== -:Author: Siargey Kachanovich :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Siargey Kachanovich :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | -| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`:Wit(W,L)` is a simplicial | -| | complex defined on two sets of points in :math:`\mathbb{R}^D`: | -| | | -| | * :math:`W` set of **witnesses** and | -| | * :math:`L \subseteq W` set of **landmarks**. | -| | | -| | The simplices are based on landmarks and a simplex belongs to the | -| | witness complex if and only if it is witnessed, that is: | -| | | -| | :math:`\sigma \subset L` is witnessed if there exists a point | -| | :math:`w \in W` such that w is closer to the vertices of | -| | :math:`\sigma` than other points in :math:`L` and all of its faces | -| | are witnessed as well. | -| | | -| | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica`. | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`witness_complex_user` | :doc:`witness_complex_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | +| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`:Wit(W,L)` is a simplicial | +| | complex defined on two sets of points in :math:`\mathbb{R}^D`: | +| | | +| | * :math:`W` set of **witnesses** and | +| | * :math:`L \subseteq W` set of **landmarks**. | +| | | +| | The simplices are based on landmarks and a simplex belongs to the | +| | witness complex if and only if it is witnessed, that is: | +| | | +| | :math:`\sigma \subset L` is witnessed if there exists a point | +| | :math:`w \in W` such that w is closer to the vertices of | +| | :math:`\sigma` than other points in :math:`L` and all of its faces | +| | are witnessed as well. | +| | | +| | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica`. | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`witness_complex_user` | :doc:`witness_complex_ref` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ -- cgit v1.2.3 From 05aafa8f990f02c121028bbfb28bb352487f864e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 22 Feb 2017 11:26:45 +0000 Subject: Fix code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2092 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: df50df0878cdb5ae351b96b4b29e4c95940ae4b8 --- src/cython/cython/tangential_complex.pyx | 54 +++++++++++------------------- src/cython/doc/tangential_complex_user.rst | 2 +- 2 files changed, 21 insertions(+), 35 deletions(-) (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx index 1b213c3a..7b54e48e 100644 --- a/src/cython/cython/tangential_complex.pyx +++ b/src/cython/cython/tangential_complex.pyx @@ -46,22 +46,9 @@ cdef extern from "Tangential_complex_interface.h" namespace "Gudhi": # TangentialComplex python interface cdef class TangentialComplex: - """TangentialComplex is a simplicial complex constructed from the finite cells - of a Delaunay Triangulation. - - The filtration value of each simplex is computed as the square of the - circumradius of the simplex if the circumsphere is empty (the simplex is - then said to be Gabriel), and as the minimum of the filtration values of - the codimension 1 cofaces that make it not Gabriel otherwise. - - All simplices that have a filtration value strictly greater than a given - alpha squared value are not inserted into the complex. - - .. note:: - - When Tangential_complex is constructed with an infinite value of alpha, the - complex is a Delaunay complex. - + """The class Tangential_complex represents a tangential complex. After the + computation of the complex, an optional post-processing called perturbation + can be run to attempt to remove inconsistencies. """ cdef Tangential_complex_interface * thisptr @@ -107,46 +94,44 @@ cdef class TangentialComplex: :param vertex: The vertex. :type vertex: int. - :returns: list of float -- the point. + :returns: The point. + :rtype: list of float """ cdef vector[double] point = self.thisptr.get_point(vertex) return point def num_vertices(self): - """This function returns the number of vertices. - - :returns: unsigned -- the number of vertices. + """ + :returns: The number of vertices. + :rtype: unsigned """ return self.thisptr.number_of_vertices() def num_simplices(self): - """This function returns the number of simplices. - - :returns: unsigned -- the number of simplices. + """ + :returns: Total number of simplices in stars (including duplicates that appear in several stars). + :rtype: unsigned """ return self.thisptr.number_of_simplices() def num_inconsistent_simplices(self): - """This function returns the number of inconsistent simplices. - - :returns: unsigned -- the number of inconsistent simplices. + """ + :returns: The number of inconsistent simplices. + :rtype: unsigned """ return self.thisptr.number_of_inconsistent_simplices() def num_inconsistent_stars(self): - """This function returns the number of inconsistent stars. - - :returns: unsigned -- the number of inconsistent stars. + """ + :returns: The number of stars containing at least one inconsistent simplex. + :rtype: unsigned """ return self.thisptr.number_of_inconsistent_stars() def create_simplex_tree(self): - """This function creates the given simplex tree from the Delaunay - Triangulation. + """Exports the complex into a simplex tree. - :param simplex_tree: The simplex tree to create (must be empty) - :type simplex_tree: SimplexTree - :returns: A simplex tree created from the Delaunay Triangulation. + :returns: A simplex tree created from the complex. :rtype: SimplexTree """ simplex_tree = SimplexTree() @@ -155,6 +140,7 @@ cdef class TangentialComplex: def fix_inconsistencies_using_perturbation(self, max_perturb, time_limit=-1.0): """Attempts to fix inconsistencies by perturbing the point positions. + :param max_perturb: Maximum length of the translations used by the perturbation. :type max_perturb: double diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 2679528c..6c3debb4 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -14,7 +14,7 @@ dimension. The running time depends only linearly on the extrinsic dimension :math:`d` and exponentially on the intrinsic dimension :math:`k`. An extensive description of the Tangential complex can be found in -:cite:`tangentialcomplex2014`). +:cite:`tangentialcomplex2014`. What is a Tangential Complex? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3 From 6d66260b62aa5c780e3ac2f0f191992aca016e24 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 9 Mar 2017 10:22:37 +0000 Subject: Strong witness cythonization Biblio for doc simplification git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2184 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c191c6b79bb14f799d6cd08ac59a6b007a7874dc --- .../example/example_nearest_landmark_table.cpp | 6 +- src/cython/cython/strong_witness_complex.pyx | 81 ++++++++++++++++++++++ src/cython/doc/alpha_complex_user.rst | 8 ++- src/cython/doc/biblio.rst | 6 -- src/cython/doc/cgal_citation.rst | 8 --- src/cython/doc/cubical_complex_user.rst | 7 +- src/cython/doc/how_to_cite_cgal.rst | 7 -- src/cython/doc/index.rst | 7 +- src/cython/doc/persistent_cohomology_user.rst | 7 +- src/cython/doc/tangential_complex_user.rst | 7 +- src/cython/doc/witness_complex_user.rst | 6 +- src/cython/gudhi.pyx.in | 1 + src/cython/include/Simplex_tree_interface.h | 7 ++ .../include/Strong_witness_complex_interface.h | 71 +++++++++++++++++++ 14 files changed, 199 insertions(+), 30 deletions(-) create mode 100644 src/cython/cython/strong_witness_complex.pyx delete mode 100644 src/cython/doc/biblio.rst delete mode 100644 src/cython/doc/cgal_citation.rst delete mode 100644 src/cython/doc/how_to_cite_cgal.rst create mode 100644 src/cython/include/Strong_witness_complex_interface.h (limited to 'src/cython/doc/tangential_complex_user.rst') diff --git a/src/Witness_complex/example/example_nearest_landmark_table.cpp b/src/Witness_complex/example/example_nearest_landmark_table.cpp index b8594212..7084d416 100644 --- a/src/Witness_complex/example/example_nearest_landmark_table.cpp +++ b/src/Witness_complex/example/example_nearest_landmark_table.cpp @@ -23,7 +23,7 @@ #define BOOST_PARAMETER_MAX_ARITY 12 #include -#include +#include #include #include @@ -35,7 +35,7 @@ int main(int argc, char * const argv[]) { using Nearest_landmark_range = std::vector>; using Nearest_landmark_table = std::vector; - using Witness_complex = Gudhi::witness_complex::Witness_complex; + using Witness_complex = Gudhi::witness_complex::Strong_witness_complex; using Simplex_tree = Gudhi::Simplex_tree<>; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; @@ -56,7 +56,7 @@ int main(int argc, char * const argv[]) { std::make_pair(2, 3), std::make_pair(3, 4)}; nlt.push_back(w4); Witness_complex witness_complex(nlt); - witness_complex.create_complex(simplex_tree, 4.1); + witness_complex.create_complex(simplex_tree, 4.1, 2); std::cout << "Number of simplices: " << simplex_tree.num_simplices() << std::endl; diff --git a/src/cython/cython/strong_witness_complex.pyx b/src/cython/cython/strong_witness_complex.pyx new file mode 100644 index 00000000..5febffbb --- /dev/null +++ b/src/cython/cython/strong_witness_complex.pyx @@ -0,0 +1,81 @@ +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair + +"""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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +cdef extern from "Strong_witness_complex_interface.h" namespace "Gudhi": + cdef cppclass Strong_witness_complex_interface "Gudhi::witness_complex::Strong_witness_complex_interface": + Strong_witness_complex_interface(vector[vector[pair[size_t, double]]] nearest_landmark_table) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, + unsigned limit_dimension) + +# StrongWitnessComplex python interface +cdef class StrongWitnessComplex: + """StrongWitnessComplex is a simplicial complex constructed from ... + + """ + + cdef Strong_witness_complex_interface * thisptr + + # Fake constructor that does nothing but documenting the constructor + def __init__(self, nearest_landmark_table=None): + """StrongWitnessComplex constructor. + + :param nearest_landmark_table: A list of nearest landmark. + :type nearest_landmark_table: list of list of pair of unsigned and double + """ + + # The real cython constructor + def __cinit__(self, nearest_landmark_table=None): + if nearest_landmark_table is not None: + self.thisptr = new Strong_witness_complex_interface(nearest_landmark_table) + + def __dealloc__(self): + if self.thisptr != NULL: + del self.thisptr + + def __is_defined(self): + """Returns true if StrongWitnessComplex pointer is not NULL. + """ + return self.thisptr != NULL + + def create_simplex_tree(self, max_alpha_square, limit_dimension = -1): + """ + :param max_alpha_square: The maximum alpha square threshold the + simplices shall not exceed. Default is set to infinity. + :type max_alpha_square: float + :returns: A simplex tree created from the Delaunay Triangulation. + :rtype: SimplexTree + """ + simplex_tree = SimplexTree() + if limit_dimension is not -1: + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension) + else: + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square) + return simplex_tree diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index f1c57248..68e53a77 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -196,4 +196,10 @@ the program output is: ([2, 3, 6], 36.5) ([2, 4, 6], 37.24489795918368) -.. :include: how_to_cite_cgal.rst +============== +CGAL citations +============== + +.. bibliography:: how_to_cite_cgal.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/biblio.rst b/src/cython/doc/biblio.rst deleted file mode 100644 index 3995e9c0..00000000 --- a/src/cython/doc/biblio.rst +++ /dev/null @@ -1,6 +0,0 @@ -Bibliography -************ - -.. bibliography:: bibliography.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/cgal_citation.rst b/src/cython/doc/cgal_citation.rst deleted file mode 100644 index bbc4ef9e..00000000 --- a/src/cython/doc/cgal_citation.rst +++ /dev/null @@ -1,8 +0,0 @@ -============== -CGAL citations -============== - -.. - bibliography:: how_to_cite_cgal.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 002a648b..692acdd9 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -153,4 +153,9 @@ Examples. End user programs are available in cython/example/ folder. -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/how_to_cite_cgal.rst b/src/cython/doc/how_to_cite_cgal.rst deleted file mode 100644 index 192e0562..00000000 --- a/src/cython/doc/how_to_cite_cgal.rst +++ /dev/null @@ -1,7 +0,0 @@ -============== -CGAL citations -============== - -.. bibliography:: how_to_cite_cgal.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index d0165588..fca63d65 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -79,4 +79,9 @@ Persistence graphical tools .. include:: persistence_graphical_tools_sum.rst -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index a68e9bdd..69be3b86 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -107,4 +107,9 @@ We provide several example files: run these examples with -h for details on thei * :download:`random_cubical_complex_persistence_example.py <../example/random_cubical_complex_persistence_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 6c3debb4..6a7e6e41 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -187,4 +187,9 @@ The output is: Tangential contains 4 vertices. Inconsistencies has been fixed. -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst index 071d8ef5..72b8d839 100644 --- a/src/cython/doc/witness_complex_user.rst +++ b/src/cython/doc/witness_complex_user.rst @@ -81,5 +81,9 @@ Example2: Computing persistence using strong relaxed witness complex Here is an example of constructing a strong witness complex filtration and computing persistence on it: -.. include:: biblio.rst +Bibliography +************ +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 2d743d4d..60bf0cd7 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -30,6 +30,7 @@ include "cython/cubical_complex.pyx" include "cython/periodic_cubical_complex.pyx" include "cython/persistence_graphical_tools.py" include "cython/witness_complex.pyx" +include "cython/strong_witness_complex.pyx" @GUDHI_CYTHON_ALPHA_COMPLEX@ @GUDHI_CYTHON_SUBSAMPLING@ @GUDHI_CYTHON_TANGENTIAL_COMPLEX@ diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 19e02ca4..4f3096c0 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -59,6 +59,13 @@ class Simplex_tree_interface : public Simplex_tree { return (result.second); } + // Do not interface this function, only used in strong witness interface for complex creation + bool insert_simplex_and_subfaces(const std::vector& complex, Filtration_value filtration = 0) { + Insertion_result result = Simplex_tree::insert_simplex_and_subfaces(complex, filtration); + Simplex_tree::initialize_filtration(); + return (result.second); + } + Filtration_value simplex_filtration(const Simplex& complex) { return Simplex_tree::filtration(Simplex_tree::find(complex)); } diff --git a/src/cython/include/Strong_witness_complex_interface.h b/src/cython/include/Strong_witness_complex_interface.h new file mode 100644 index 00000000..e59e58ea --- /dev/null +++ b/src/cython/include/Strong_witness_complex_interface.h @@ -0,0 +1,71 @@ +/* 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 STRONG_WITNESS_COMPLEX_INTERFACE_H +#define STRONG_WITNESS_COMPLEX_INTERFACE_H + +#include +#include + +#include "Simplex_tree_interface.h" + +#include +#include // std::pair +#include +#include + +namespace Gudhi { + +namespace witness_complex { + +class Strong_witness_complex_interface { + using Nearest_landmark_range = std::vector>; + using Nearest_landmark_table = std::vector; + + public: + Strong_witness_complex_interface(Nearest_landmark_table& nlt) { + witness_complex_ = new Strong_witness_complex(nlt); + } + + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, + std::size_t limit_dimension) { + witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension); + simplex_tree->initialize_filtration(); + } + + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, + double max_alpha_square) { + witness_complex_->create_complex(*simplex_tree, max_alpha_square, std::numeric_limits::max()); + simplex_tree->initialize_filtration(); + } + + private: + Strong_witness_complex* witness_complex_; + +}; + +} // namespace witness_complex + +} // namespace Gudhi + +#endif // STRONG_WITNESS_COMPLEX_INTERFACE_H + -- cgit v1.2.3