7

Suppose we want to position some points in space, given that we know at least some of the distances between them. How can we determine if this is possible? And if it is possible, can we determine the least dimension in which it is possible and algorithmically find a possible (clearly not unique) solution? This is basically the problem of physically constructing a weighted graph, where the edges represent distances between two vertices, and we don't care how far apart are any pairs of vertices not joined by an edge.

Clearly we should check that the given distances satisfy the triangle equality, but for a fixed dimension this itself is not enough. Suppose we know that a subset of three points A, B and C each lie a (Euclidean) distance of one from each other. Then there is no way to position them in one dimension. However, in two-dimensional space they can be physically constructed, as the vertices of an equilateral triangle. So there was no violation of the triangle inequality, which means the one-dimensional issue we hit was some other problem. Similarly if point D must be at unit distance from A, B and C then two dimensions are not enough, but a three-dimensional tetrahedron would resolve the problem. If A, B, C, D, E must all be at unit distance from each other, then even three dimensions are not enough...

An algebraic way to look at the three-point case is that equations $(x_A - x_B)^2 = 1^2$, $(x_B - x_C)^2 = 1^2$, $(x_C - x_A)^2 = 1^2$ are inconsistent. But we can extend to another dimension, $(x_A - x_B)^2 + (y_A - y_B)^2 = 1^2$ etc, to make them consistent (albeit under-determined). So long as there is no violation of the triangle inequality, can we always keep adding extra dimensions until the system of simultaneous quadratic equations becomes consistent? Is there an algorithm to determine whether the equations are consistent? (Bear in mind we will not necessarily know the distance between each pair of points.) Is there instead a more geometric approach we can use?

Related questions: Define positions of a set of points given (only) the distances between them (but unlike my question, all distances are given rather than only only a subset of them), When can we achieve given distances between four points? and When can a weighted graph be embedded in a metric space? (not necessarily Euclidean, and which has nice albeit trivial answer). This interesting question didn't receive an answer, but looks at sets of distances rather than assigning the distances to have to lie between particular vertices: Sets of distances between points that do not form distinct shapes. Closely related question on CS Theory SE: Best way to determine the minimum dimension of a structure given only distances between points (partially answers my question in terms of finding the minimum dimension, but not determining whether it's possible in some dimension- thanks @D.W. for finding this one).

Silverfish
  • 1,620
  • 21
  • 33

2 Answers2

6

Determining the least dimension in which it is possible is hard even in restricted cases. Suppose that all the distances which are specified are equal to $1$, and we want to know if the graph can be embedded in $\mathbb R^2$. This is equivalent to trying to determine if the graph is a unit distance graph, and Wikipedia says:

It is NP-hard, and more specifically complete for the existential theory of the reals, to test whether a given graph is a subgraph of a unit distance graph, or is a strict unit distance graph.

(The citation is Schaefer, 2013. We're looking at the "subgraph of a unit distance graph" case here, since we don't know whether the distances left unspecified are equal to $1$.)

If we only want to know that the graph can be embedded in some dimension, but we don't care which one, then it's possible that the problem becomes easier. If we had all the distances given, then the question becomes equivalent to checking that all Cayley–Menger determinants giving the volumes of simplices formed by subsets of the points are nonnegative.

With some distances unknown, this is almost-but-not-quite a semidefinite program: we want $$(-1)^{n+1} \begin{vmatrix} 0 & d_{01}^2 & d_{02}^2 & \cdots & d_{0n}^2 & 1 \\ d_{01}^2 & 0 & d_{12}^2 & \cdots & d_{1n}^2 & 1 \\ d_{02}^2 & d_{12}^2 & 0 & \cdots & d_{2n}^2 & 1 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ d_{0n}^2 & d_{1n}^2 & d_{2n}^2 & \cdots & 0 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 0 \end{vmatrix} \ge 0$$ and we want the same thing to happen for all principal submatrices of this matrix which include the last row and column. If it weren't for that italicized condition, then we could just write down a matrix with some variable entries that we want to be positive semidefinite, which is a tractable problem; I don't know how much the italicized condition ruins our life.

Misha Lavrov
  • 142,276
  • Interesting! A few bits I'm not sure I grasp: "Suppose all the distances which are specified are equal to 1, and we want to know if the graph can be embedded in $R^2$. This is equivalent to trying to determine if the graph is a unit-distance graph" - is it quite equivalent? If I understand the link correctly, all unit-length distances must be granted an edge in a unit distance graph, but in the original problem we don't know if there are additional unit distances that were left unspecified. Obviously similar problems but is the unit distance problem really a special case of my problem? – Silverfish Sep 19 '22 at 00:55
  • The triangle inequality checks if a triangle can be constructed given the distances between three points. Is the Cayley–Menger determinant test basically its generalisation to $n>3$ points? Suppose I consider each subset of points for which all mutual distances are known. Clearly I should check they pass this test: this improves on only checking the triangle inequality & may rule out many additional cases. But if this test passes, is that sufficient to guarantee a solution exists provided we move to a high enough dimension? Or are we still not "out of the woods" even on the existence question? – Silverfish Sep 19 '22 at 01:12
  • 2
    The triangle inequality is indeed not enough in higher dimensions. For example, suppose that you have $4$ points and five of the distances between them are $1$; geometrically, we have two equilateral triangles attached along an edge like a hinge. Then the sixth distance can be at most $\sqrt 3$, even though the triangle inequality only tells us it is at most $2$. – Misha Lavrov Sep 19 '22 at 01:14
  • Thank you! More a comment on my previous comment: in the 3 point case, the Cayley-Menger determinant recovers Heron's formula, and checking whether Heron's formula gives a non-negative area is the same as checking the triangle inequality holds, so it's probably fair to call the condition that Cayley-Menger determinants of the subsets are all positive a generalisation of the triangle inequality – Silverfish Sep 19 '22 at 01:26
  • 2
    @Silverfish I've added a better source on the NP-hardness. Both versions of the unit distance graph problem are NP-hard, including the one we care about here. – Misha Lavrov Sep 19 '22 at 15:32
  • 1
    That's great! I hope you don't mind but I will wait a while before accepting this answer, in case anyone comes forward with some further insight into the case where we don't care about which dimension, just whether it is possible at all. – Silverfish Sep 20 '22 at 00:42
  • 2
    That's very reasonable and I admit that I am also curious to see if anyone will come up with anything. – Misha Lavrov Sep 20 '22 at 00:43
2

Determining the minimum dimension is unfortunately NP-hard. See Best way to determine the minimum dimension of a structure given only distances between points on CSTheory.SE. That answer says that the problem is known as "low-dimensional Euclidean distance matrix completion or the low-dimensional Euclidean embedding of a weighted graph".

If we don't care about the dimension, I don't know whether there is an algorithm to test whether any solution exists or not.

See also multidimensional scaling, which concerns itself with finding an approximate solution rather than an exact solution, i.e., is there any solution that approximately matches the given distances. The obvious approach to try to tackle this in practice would be to use some off-the-shelf optimization algorithm to minimize the sum of squared errors, as explained on Wikipedia.

D.W.
  • 4,540
  • Nice link, thanks! As you say, not quite a duplicate due to it considering only the minimum dimension. But it does back up Misha Lavrov's answer. – Silverfish Oct 28 '23 at 10:22
  • I've given the 100 point bonus because it's so helpful to know the right search-term for this problem – Silverfish Nov 04 '23 at 20:49