views:

52

answers:

1

hey, I have been given a problem, I basically have been given a piece of grid paper of arbitary size and have to develop a distance matrix using only the coordinates for each of the grid points on the page.

I'm thinking the best approach would be something like the Floyd-Warshall or Djikstra algorithms for shortest path pair, but don't know how to adapt it to coordinate distances, as all the documentation uses a pre-determined distance matrix. so any help would be grand

A: 

the distance matrix contains simply the distances to all other points.

Basically, you just have to calculate the distances using an appropriate metric. If you want the "normal" distance, it's sqrt((x1-x2)^2+(y1-y2)^2) where (x/y) are the coordinates of a point in mm / inches. If you want the distance on the paper just following the lines its |x1-x2|+|y1-y2|. Graph algorithms would be a overkill unless you have walls on the paper.

Tobias Langner
ok all well and good, but now i need to construct a distance matrix using the shortest distance between neighbors for every element to every element. taking note the possibility of obsticals and the paper not being uniformially flat
davechip
I think your question is to undetailed to answer it correctly.
Tobias Langner