scikit-tda / kepler-mapper

Kepler Mapper: A flexible Python implementation of the Mapper algorithm.
https://kepler-mapper.scikit-tda.org
MIT License
630 stars 183 forks source link

Identify clusters of nodes #203

Open mhmism opened 3 years ago

mhmism commented 3 years ago

Hello,

Thanks a lot for this wonderful mapper. I have been impressed by it so far.

Is there a way to automatically identify clusters of closely connected nodes within the TDA graph? I have seen a few articles mentioning that they applied a Morse-clustering algorithm, but not sure how can apply it to the TDA graphs by KeplerMapper.

Any guidance in this direction will be extremely appreciated.

sauln commented 3 years ago

Hi @mhmism, you should be able to use any graph clustering method you'd like. For one example, you could convert the resulting graph to networkx format (using the networkx adapter), and then using sklearn's spectralclustering algorithm for your clustering.

I'm sure there are some kinks to work out around edge lengths, but this approach should work.

mhmism commented 3 years ago

Many thanks for your reply! this is really helpful.

Since I'm using spectral clustering already in my TDA analysis. I'm not sure if it will make sense for me to use it again for modularity detection.

I'm considering using the Louvain algorithm, https://python-louvain.readthedocs.io/en/latest/ What do you think?

Kind regards Mahmoud

sauln commented 3 years ago

🤷 I'm not familiar with Louvain, but from a cursory glance at the page it seems like it would work.

fwiw, I can't think of any problem with using spectral clustering twice.