I'm currently learning C and have recently written a program to find the minimum spanning tree using Prim's algorithm. This program works fine, but requires the cost of each edge (of course).
If I want to find the MST for a large number of 2D co-ordinates (e.g. 50), I need to find the Euclidian Distance Matrix for the points first. My question is: can this be done in C without computing
distance = sqrt((x2-x1)^2+(y2-y1)^2)
for every single point, for example by using loops?
I have been trying to use
arrayX[] = {x1,x2,x3,...xn}
arrayY[] = {y1,y2,y3,...yn}
and using a for
loop, though have been unable to do so due to my inexperience (if this was 1D, of course, this would be very easy!).
Can anyone give me any pointers as to what to do? Thanks in advance!