Most common clustering methods like K-means fail to compute clusters when they have a nonlinear geometry that is not captured by Euclidean distance.

By replacing Euclidean distance with Fermat distance you can use your favorite clustering algorithm with substantial improvement.

In this tutorial we cluster digits from MNIST data set with an algorithm as simple as K-means where Euclidean distance is replaced by Fermat distance.