From 518acce63202c7b89fa3f76467e50eee7630cf62 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 16 Feb 2017 14:58:11 +0000 Subject: Remove pandas examples and use of OFF files interfaces to be more consistent (pandas interface is not that hard to be done) Add of distance matrix in Rips git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2081 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3a3b24f0824eed2710edb5bf17d120039973bf62 --- src/cython/doc/installation.rst | 6 +- src/cython/doc/persistent_cohomology_user.rst | 3 +- src/cython/doc/rips_complex_user.rst | 126 +++++++++++++++++++++++--- 3 files changed, 121 insertions(+), 14 deletions(-) (limited to 'src/cython/doc') diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index 12d35821..20d97b3c 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -112,8 +112,9 @@ The following examples require the `Matplotlib `_: * :download:`alpha_complex_diagram_persistence_from_off_file_example.py <../example/alpha_complex_diagram_persistence_from_off_file_example.py>` * :download:`gudhi_graphical_tools_example.py <../example/gudhi_graphical_tools_example.py>` * :download:`periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>` - * :download:`rips_complex_diagram_persistence_with_pandas_interface_example.py <../example/rips_complex_diagram_persistence_with_pandas_interface_example.py>` + * :download:`rips_complex_diagram_persistence_from_off_file_example.py <../example/rips_complex_diagram_persistence_from_off_file_example.py>` * :download:`rips_persistence_diagram.py <../example/rips_persistence_diagram.py>` + * :download:`rips_complex_diagram_persistence_from_distance_matrix_file_example.py <../example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` Numpy @@ -130,6 +131,7 @@ The following examples require the `NumPy `_: * :download:`alpha_complex_diagram_persistence_from_off_file_example.py <../example/alpha_complex_diagram_persistence_from_off_file_example.py>` * :download:`gudhi_graphical_tools_example.py <../example/gudhi_graphical_tools_example.py>` * :download:`periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>` - * :download:`rips_complex_diagram_persistence_with_pandas_interface_example.py <../example/rips_complex_diagram_persistence_with_pandas_interface_example.py>` + * :download:`rips_complex_diagram_persistence_from_off_file_example.py <../example/rips_complex_diagram_persistence_from_off_file_example.py>` * :download:`rips_persistence_diagram.py <../example/rips_persistence_diagram.py>` + * :download:`rips_complex_diagram_persistence_from_distance_matrix_file_example.py <../example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index 4ca4805d..d264a011 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -101,8 +101,9 @@ We provide several example files: run these examples with -h for details on thei * :download:`alpha_complex_from_points_example.py <../example/alpha_complex_from_points_example.py>` * :download:`periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>` - * :download:`rips_complex_diagram_persistence_with_pandas_interface_example.py <../example/rips_complex_diagram_persistence_with_pandas_interface_example.py>` + * :download:`rips_complex_diagram_persistence_from_off_file_example.py <../example/rips_complex_diagram_persistence_from_off_file_example.py>` * :download:`rips_persistence_diagram.py <../example/rips_persistence_diagram.py>` + * :download:`rips_complex_diagram_persistence_from_distance_matrix_file_example.py <../example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py>` * :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>` diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index be9481de..a5d17e19 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -38,16 +38,16 @@ set with :math:`max(filtration(4,5), filtration(4,6), filtration(5,6))`. And so 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 ---------------------------------- +Point cloud +----------- -Example from a point cloud and a distance function -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Example from a point cloud +^^^^^^^^^^^^^^^^^^^^^^^^^^ -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. +This example builds the one skeleton graph from the given points, and max_edge_length value. +Then it creates a :doc:`Simplex_tree ` with it. -Then, it is asked to display information about the simplicial complex. +Finally, it is asked to display information about the simplicial complex. .. testcode:: @@ -63,7 +63,8 @@ Then, it is asked to display information about the simplicial complex. for filtered_value in simplex_tree.get_filtered_tree(): print(filtered_value) -The output is: +When launching (Rips maximal distance between 2 points is 12.0, is expanded +until dimension 1 - one skeleton graph in other words), the output is: .. testoutput:: @@ -90,10 +91,11 @@ The output is: 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. +This example builds the :doc:`Rips_complex ` from the given +points in an OFF file, and max_edge_length value. +Then it creates a :doc:`Simplex_tree ` with it. -Then, it is asked to display information about the Rips complex. +Finally, it is asked to display information about the Rips complex. .. testcode:: @@ -131,3 +133,105 @@ the program output is: ([0, 3], 9.433981132056603) ([4, 6], 9.486832980505138) ([3, 6], 11.0) + +Distance matrix +--------------- + +Example from a distance matrix +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This example builds the one skeleton graph from the given distance matrix, and max_edge_length value. +Then it creates a :doc:`Simplex_tree ` with it. + +Finally, it is asked to display information about the simplicial complex. + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(distance_matrix=[[], + [6.0827625303], + [5.8309518948, 6.7082039325], + [9.4339811321, 6.3245553203, 5], + [13.0384048104, 15.6524758425, 8.94427191, 12.0415945788], + [18.0277563773, 19.6468827044, 13.152946438, 14.7648230602, 5.3851648071], + [17.88854382, 17.1172427686, 12.0830459736, 11, 9.4868329805, 7.2801098893]], + 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) + +When launching (Rips maximal distance between 2 points is 12.0, is expanded +until dimension 1 - one skeleton graph in other words), 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.3851648071) + ([0, 2], 5.8309518948) + ([0, 1], 6.0827625303) + ([1, 3], 6.3245553203) + ([1, 2], 6.7082039325) + ([5, 6], 7.2801098893) + ([2, 4], 8.94427191) + ([0, 3], 9.4339811321) + ([4, 6], 9.4868329805) + ([3, 6], 11.0) + +Example from OFF file +^^^^^^^^^^^^^^^^^^^^^ + +This example builds the :doc:`Rips_complex ` from the given +points in an OFF file, and max_edge_length value. +Then it creates a :doc:`Simplex_tree ` with it. + +Finally, it is asked to display information about the Rips complex. + + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(csv_file='full_square_distance_matrix.csv', 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.3851648071) + ([0, 2], 5.8309518948) + ([0, 1], 6.0827625303) + ([1, 3], 6.3245553203) + ([1, 2], 6.7082039325) + ([5, 6], 7.2801098893) + ([2, 4], 8.94427191) + ([0, 3], 9.4339811321) + ([4, 6], 9.4868329805) + ([3, 6], 11.0) -- cgit v1.2.3