Consider an i.i.d. sample from unknown density function supported on manifold embedded in a high dimensional Euclidean space. We tackle the problem of learning distance between points, able to capture both geometry and underlying density. define such prove convergence, as size goes infinity, macroscopic one that we call Fermat it minimizes path functional, resembling principle optics. The proof...