I recode the component from your link
It works very well, in 2D or 3D and it is very simple, not many thinks to look at. I will try to rewrite it in C#.
k_mean2.ghx (374.8 KB)
Like advised by David here a version, without random seed, in C#, without datatree as Input. It seems to work well but I had not tested it a lot. It gives the same result as the VB component.
k_mean2.ghx (410.3 KB)