Minimum/maximum edge length of the mesh in the entire domain

Hi everyone, I need help from you. I’m trying to find the minimum/maximum edge length of the mesh in the entire domain. I tried the following two options but neither of them worked well for my test case, see the figure below as well as the code copied at the end (sorry as new user I cannot upload file). My test case is a 1 by 1 square where the vertical edge is uniformly divided into four parts while horizontal one into two parts. For me, the minimum edge should be 0.25 and maximum should be sqrt(0.25^2+0.5^2) = 0.559.

In method 1 I use the following codes

Vh0 h1 = hTriangle;
real hmax = h1[].max;
real hmin = h1[].min;

However, both hmax and hmin have the value of 0.559. I cannot get the correct minimum edge length.

In method 2 I use the macro provided by the FreeFEM document with the name MeshSizecomputation (Static problems), while it gives me the minimum edge length of 0.375 and maximum edge length of 0.467, neither of which is correct.

If you can provide any help that will be much appreciated!

below is my code.

/* working domain */
real x0 = 0;
real x1 = 1;
real y0 = 0;
real y1 = 1;
mesh Th = square(2,4,[x0+(x1-x0)*x,y0+(y1-y0)*y]);
plot(Th);

/* Finite Element spaces */
fespace Vh(Th,P1);
fespace Vh0(Th,P0);

/* meshsize, method 1 /
Vh0 h1 = hTriangle;
real hmax = h1[].max; /
maximum mesh size /
real hmin = h1[].min; /
minimun mesh size */
cout << "hmax = " << hmax << ", hmin = " << hmin << endl;

/* meshsize, method 2 */
macro MeshSizecomputation (Th, Vh, h)
{
real[int] count(Th.nv);
/mesh size (lenEdge = integral(e) 1 ds)/
varf vmeshsizen (u, v) = intalledges(Th, qfnbpE=1)(v);
/number of edges per vertex/
varf vedgecount (u, v) = intalledges(Th, qfnbpE=1)(v/lenEdge);
/mesh size/
count = vedgecount(0, Vh);
h[] = 0.;
h[] = vmeshsizen(0, Vh);
cout << "count min = " << count.min << " max = " << count.max << endl;
h[] = h[]./count;
cout << "-- bound meshsize = " << h[].min << " " << h[].max << endl;
} //

Vh h;
MeshSizecomputation(Th, Vh, h)