Socioeconomic segregation has an important role in the emergence of large-scale inequalities in urban areas. Most of the available measures of spatial segregation depend on the scale and size of the system under study, or neglect large-scale spatial correlations, or rely on ad-hoc parameters, making it hard to compare different systems on equal grounds. We propose here a family of non-parametric measures for spatial distributions, based on the statistics of the trajectories of random walks on graphs associated to a spatial system. These quantities provide a consistent estimation of segregation in synthetic spatial patterns, and we use them to analyse the ethnic segregation of metropolitan areas in the US and the UK. We show that the spatial diversity of ethnic distributions, as measured through diffusion on graphs, allow us to compare the ethnic segregation of urban areas having different size, shape, or peculiar microscopic characteristics, and exhibits a strong association with socio-economic deprivation.