Nonparametric Density Estimation on A Graph: Learning Framework, Fast Approximation and Application in Image Segmentation