Material about Mesh Density

Hello, I want to make material based on mesh density. I’m going to make it red for high density and blue for low density. So I want to calculate the distance of the vertex in the mesh to make a blueprint so that I can know where the vertex is concentrated, but I don’t know what to do. Can you give me some advice?