# Calculate of total length of edges in Voronoi diagram

Does anyone have any suggestions how to determine the total sum of edges length in a Voronoi diagram?

• Welcome to Mathematica.SE. Are you sure you are posting on the right site? There is nothing in your question making it clear that it is concerned with Mathematica software. Feb 25, 2019 at 22:48

SeedRandom[1234];
R = VoronoiMesh[RandomReal[{-1, 1}, {20, 2}]];
Total[PropertyValue[{R, 1}, MeshCellMeasure]]


31.1601

• I am very grateful for your response, Henrik. Thank you. Feb 26, 2019 at 22:47
• Great to hear that! You're welcome. Feb 26, 2019 at 22:48
SeedRandom[1]
pts = RandomReal[{-1, 1}, {5, 2}];
vm = VoronoiMesh[pts]


You can use the property "EdgeLengths":

Total @ vm["EdgeLengths"]


12.2894

If you need the lengths of individual edges:

lengths = RegionMeasure /@ MeshPrimitives[vm, 1]


{0.60034, 0.672996, 0.403197, 0.793131, 0.596543, 0.920977, 1.03974, 1.12238, 0.322772, 1.05995, 0.854316, 0.985915, 0.0806386, 0.844254, 0.264125, 1.72809}

Total[lengths]


12.2894

Alternatively, you can use ArcLength in place of RegionMeasure:

lengths == ArcLength /@ MeshPrimitives[vm, 1]
True

• Thank you very much for your response, it has been very helpful for me. Feb 26, 2019 at 22:44
• @MatiGer, you are most welcome.
– kglr
Feb 26, 2019 at 22:51