Davies-Bouldin index for optimal LS partition

Input: partition Π of the set 𝒜 ⊂ (ℝ^n);
Output: DB index of the partition Π;
Submodules: none needed

Clear[VDB]
VDB[PI_]:=Module[{FF,VV,mj,sum=0},
FF=VV=Table[0,{j,Length[PI]}];
z=Table[Mean[WeightedData[PI[[j,All,2]],PI[[j,All,1]]]],{j,Length[PI]}];
Do[
mj=Length[PI[[j]]];
FF[[j]]=Sum[PI[[j,i,1]]*Norm[PI[[j,i,2]]-z[[j]]]^2,{i,mj}];
VV[[j]]=Sqrt[FF[[j]]/Sum[PI[[j,i,1]],{i,mj}]]
   ,{j,Length[PI]}];
Do[
max={};
Do[
If[i≠j,max=Append[max,(VV[[i]]+VV[[j]])/Norm[z[[i]]-z[[j]]]]]
,{i,Length[PI]}];
sum=sum+Max[max]
,{j,Length[PI]}];
sum/Length[PI]
            ]