GUDHI / gudhi-devel

The GUDHI library is a generic open source C++ library, with a Python interface, for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.
https://gudhi.inria.fr/
MIT License
245 stars 65 forks source link

[python] periodic alpha complex #684

Open ajouellette opened 1 year ago

ajouellette commented 1 year ago

Hi, I'm trying to use alpha complexes to compute persistent homology of point clouds in 3D periodic boxes. I see that the C++ library supports 3D periodic alpha complexes (I think), but the Python interface doesn't have this option. Is this something that could be implemented relatively easily? Where would one start with this?

Thanks!

mglisse commented 1 year ago

I see that the C++ library supports 3D periodic alpha complexes (I think)

Yes.

but the Python interface doesn't have this option.

See #378, CGAL is in the process of significantly changing this feature, so we were waiting to write the interface after the change. It looks like that PR may be stalled though, we'll have to ask them what the status is.

Is this something that could be implemented relatively easily? Where would one start with this?

Probably a new class, similar to the current AlphaComplex wrapper, but that wraps the 3D version instead. There was a version (visible in the history?) that used the non-periodic 3d case inside AlphaComplex when the dimension is 3, but that was rather messy.

Or if the periodic alpha-complex is already available in the official cgal python bindings, you could build one that way, and convert it to a simplex tree in python, but I don't think it is available.

ajouellette commented 1 year ago

I found this commit that removed the 3D-specific AlphaComplex, but I'm getting lost in the C++ code. Is there a good way to resurrect this for use with periodic boundaries?

Or is this not worth the mess due to the upcoming changes in CGAL?

Thanks for your help.

mglisse commented 1 year ago

We don't know how big the changes in CGAL are going to be in terms of API, maybe small, maybe large. We should have a look at that PR to get an idea.

For the 3d periodic case, we haven't really decided if we should try to include it in AlphaComplex, but that may become very messy, or if we should do a special class just for 3d, similar to what you found (and also one for 2d? should it handle the non-periodic case as well?).

If you want to experiment quickly, I think you could take the factory code and the .pyx from that commit (and the CMakeLists.txt changes I guess), change the last template parameter to true at the end of the factory code, add the bounding box to the constructor arguments, and tweak things until it compiles.

VincentRouvreau commented 1 year ago

@ajouellette 3D-specific AlphaComplex has been removed on gudhi 3.6.0. I think you should start from gudhi 3.5.0 (git tag or from gudhi user version 3.5.0) to resurrect the alpha complex 3d python binding. You can also find some C++ examples of Periodic Alpha complexes in 3d in this unitary test or in this utility.