ripser-plusplus icon indicating copy to clipboard operation
ripser-plusplus copied to clipboard

return indices of birth/death generating edges

Open killianfmeehan opened this issue 2 years ago • 2 comments

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.

killianfmeehan avatar May 20 '22 06:05 killianfmeehan

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!

simonzhang00 avatar May 24 '22 17:05 simonzhang00

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

killianfmeehan avatar May 25 '22 01:05 killianfmeehan