Find Distance Between Points That Have Only Relative Coordinates

502 Views Asked by At

Let's say I have an array of points, each of them defined by their distance to surrounding points, rather than by coordinates on a map. For instance, NY's location would be defined by its distance to Pennsylvania and Maryland, etc. And Washington is defined by its distance to Oregon and Idaho, etc.

Assuming each point is defined by a limited number of connections, how would I find the distance between two points that don't share connections, such as NY and WA?

The scenario is a map of node points in 3D space, and rather than defining their coordinates in terms of XYZ on a graph, I'm defining their distances between each other in terms of XYZ. So if Point A is in some location in space with a number of surrounding neighbors, and Point Z is in some other location in space with a number of other surrounding neighbors, I want to be able to find the distance between A and Z.

I've already considered a flood method, similar to how simpler pathfinding works, flooding a temporary connection map and finding the shortest path drawn and using that path to figure out a straight line distance. This method seems very costly, however.

1

There are 1 best solutions below

3
On BEST ANSWER

Using graph theory you'll get the shortest distance between the two nodes pretty easily assuming the are indirectly connected (this is a classic and you'll find a zillion algorithms and their implementations online).

If you want the euclidian distance then after finding a path (you're not forced to have the shortest path, although it might lead to quicker computation) then you'll have to solve a system of equations. Note that for this to work you need to have 2 (or 3 in 3 dimensions) known distance for each and every single node of your path (this might lead you to add nodes outside the path, this is ok as long as those extra nodes also respect the previous rule)