Theshold Dynamics For Statistical Density Estimation And Graph Clustering