Shortest distance of a location to X number of locations

95 Views Asked by At

Anyone have advice on this problem?

"Shortest distance of a location to X number of locations"

First lets assume X=3 (3 addresses)

We know the following:

Distance in Miles or KM of : A1 to A1, A1 to A2, A1 to A3 | A2 to A1, A2 to A2, A2 to A3 | A3 to A1, A3 to A2, A3 to A3

with this we can put it in a matrix and following numbers = KM for example.

   A1  A2  A3
A1  0  2   1

A2  2  0   3

A3  1  3   0    

If we were to sum the number across of each row or each column, the shortest point (A1 or A2 or A3) to all 3 different location would be the smallest number.

   A1  A2  A3
A1  0  2   1    =   3KM 

A2  2  0   3    =   5KM

A3  1  3   0    =   4KM

So as you can see location A1 has the shortest distance, where as A2 is the longest. Meaning if I were to send 3 people from A1, one person go to A1 and another A2 and another A3. The sum of the distance as per matrix and the calculation is 3KM which is the shortest, where as if I were to send 3 people from A2, the sum of distances 3 people walked is the longest at 5KM. This method still works if X is a large number say 100 or 200 addresses.

My question is what if X=200 but this time, I want to find 2 or 3 or even 4 shortest distances.

I thought about this question, and I think first I would need to somehow split the 200 locations in to groups of 4 (If I am looking for 4 shortest locations to all 200 locations) then within each 50 locations, I would use above method to find shortest distance to all 4 groups and that is my answer.

Any one has answer on how to split the X locations in to Y groups(Y group of locations)?

Or has another way to solve this problem?