Density regions algorithm