simonzhang00 / ripser-plusplus

Ripser++: GPU-accelerated computation of Vietoris–Rips persistence barcodes
MIT License
98 stars 14 forks source link

return indices of birth/death generating edges #11

Open killianfmeehan opened 2 years ago

killianfmeehan commented 2 years ago

Hello and thank you for this library! I have it installed and running with no problems. What I'd like to know is if I can get more than just the birth/death times to be returned by the main "run" function. (I'm not literate in C++, so I'm running this through python with the tools helpfully included in the library -- thanks for that by the way.)

Specifically, I would like to be able to access the information of where that birth/death time came from. Ideally, I'm looking for the precise edge (row/column indices of the distance matrix) from which the birth or death time is being derived. Alternatively, knowing the simplex responsible for a birth/death time (as long as that information can in turn tell me which data points/indices of the distance matrix gave rise to that simplex) would work too.

Whatever you're able to tell me, thanks so much for your time.

simonzhang00 commented 2 years ago

Hi,

You will have to modify the CUDA code in order to get back the vertex indices from the distance matrix.

I suggest you look into the simplex data structure diameter_index_t_struct: https://github.com/simonzhang00/ripser-plusplus/blob/master/ripserplusplus/ripser%2B%2B.cu#L122

Since the pairs are being determined on these lines: https://github.com/simonzhang00/ripser-plusplus/blob/master/ripserplusplus/ripser%2B%2B.cu#L2139 https://github.com/simonzhang00/ripser-plusplus/blob/master/ripserplusplus/ripser%2B%2B.cu#L2176

and printed at these lines: https://github.com/simonzhang00/ripser-plusplus/blob/master/ripserplusplus/ripser%2B%2B.cu#L2183

You should be able to retrieve the indexs instead of just the diameters by forming the struct {column_to_reduce.index,pivot.index} This index is just the combinatorial index, which is used to encode a high dimensional simplex as a single integer. You can use some of the existing code to extract the list of vertex indices from a combinatorial index (decode).

Good luck!

killianfmeehan commented 2 years ago

That's perfect -- thanks so much for your help!