# Unit distance graph

In mathematics, particularly geometric graph theory, a unit distance graph is a graph formed from a collection of points in the Euclidean plane by connecting two points whenever the distance between them is exactly one. To distinguish these graphs from a broader definition that allows some non-adjacent pairs of vertices to be at distance one, they may also be called strict unit distance graphs or faithful unit distance graphs. As a hereditary family of graphs, they can be characterized by forbidden induced subgraphs. The unit distance graphs include the cactus graphs, the matchstick graphs and penny graphs, and the hypercube graphs. The generalized Petersen graphs are non-strict unit distance graphs.
An unsolved problem of Paul Erdős asks how many edges a unit distance graph on $n$ vertices can have. The best known lower bound is slightly above linear in $n$—far from the upper bound, proportional to $n^{4/3}$. The number of colors required to color unit distance graphs is also unknown (the Hadwiger–Nelson problem): some unit distance graphs require five colors, and every unit distance graph can be colored with seven colors. For every algebraic number there is a unit distance graph with two vertices that must be that distance apart. According to the Beckman–Quarles theorem, the only plane transformations that preserve all unit distance graphs are the isometries.
It is possible to construct a unit distance graph efficiently, given its points. Finding all unit distances has applications in pattern matching, where it can be a first step in finding congruent copies of larger patterns. However, determining whether a given graph can be represented as a unit distance graph is NP-hard, and more specifically complete for the existential theory of the reals.

## Definition

The unit distance graph for a set of points in the plane is the undirected graph having those points as its vertices, with an edge between two vertices whenever their Euclidean distance is exactly one. An abstract graph is said to be a unit distance graph if it is possible to find distinct locations in the plane for its vertices, so that its edges have unit length and so that all non-adjacent pairs of vertices have non-unit distances. When this is possible, the abstract graph is isomorphic to the unit distance graph of the chosen locations. Alternatively, some sources use a broader definition, allowing non-adjacent pairs of vertices to be at unit distance. The resulting graphs are the subgraphs of the unit distance graphs (as defined here). Where the terminology may be ambiguous, the graphs in which non-edges must be a non-unit distance apart may be called strict unit distance graphs or faithful unit distance graphs. The subgraphs of unit distance graphs are equivalently the graphs that can be drawn in the plane using only one edge length. For brevity, this article refers to these as "non-strict unit distance graphs".
Unit distance graphs should not be confused with unit disk graphs, which connect pairs of points when their distance is less than or equal to one, and are frequently used to model wireless communication networks.

## Examples

The complete graph on two vertices is a unit distance graph, as is the complete graph on three vertices (the triangle graph), but not the complete graph on four vertices. Generalizing the triangle graph, every cycle graph is a unit distance graph, realized by a regular polygon. Two finite unit distance graphs, connected at a single shared vertex, yield another unit distance graph, as one can be rotated with respect to the other to avoid undesired additional unit distances. By thus connecting graphs, every finite tree or cactus graph may be realized as a unit distance graph.
$Q_{4}$
$H(3,3)$
Any Cartesian product of unit distance graphs produces another unit distance graph; however, the same is not true for some other common graph products. For instance, the strong product of graphs, applied to any two non-empty graphs, produces complete subgraphs with four vertices, which are not unit distance graphs. The Cartesian products of path graphs form grid graphs of any dimension, the Cartesian products of the complete graph on two vertices are the hypercube graphs, and the Cartesian products of triangle graphs are the Hamming graphs $H(d,3)$.
Other specific graphs that are unit distance graphs include the Petersen graph, the Heawood graph, the wheel graph $W_{7}$ (the only wheel graph that is a unit distance graph), and the Moser spindle and Golomb graph (small 4-chromatic unit distance graphs). All generalized Petersen graphs, such as the Möbius–Kantor graph depicted, are non-strict unit distance graphs.
Matchstick graphs are a special case of unit distance graphs, in which no edges cross. Every matchstick graph is a planar graph, but some otherwise-planar unit distance graphs (such as the Moser spindle) have a crossing in every representation as a unit distance graph. Additionally, in the context of unit distance graphs, the term 'planar' should be used with care, as some authors use it to refer to the plane in which the unit distances are defined, rather than to a prohibition on crossings. The penny graphs are an even more special case of unit distance and matchstick graphs, in which every non-adjacent pair of vertices are more than one unit apart.

## Properties
### Number of edges

$n$
Paul Erdős (1946) posed the problem of estimating how many pairs of points in a set of $n$ points could be at unit distance from each other. In graph-theoretic terms, the question asks how dense a unit distance graph can be, and Erdős's publication on this question was one of the first works in extremal graph theory. The hypercube graphs and Hamming graphs provide a lower bound on the number of unit distances, proportional to $n\log n.$ By considering points in a square grid with carefully chosen spacing, Erdős found an improved lower bound of the form $n^{1+c/\log \log n}$ for a constant $c$, and offered $500 for a proof of whether the number of unit distances can also be bounded above by a function of this form. The best known upper bound for this problem is ${\sqrt[{3}]{\frac {29n^{4}}{4}}}\approx 1.936n^{4/3}.$ This bound can be viewed as counting incidences between points and unit circles, and is closely related to the crossing number inequality and to the Szemerédi–Trotter theorem on incidences between points and lines.
For small values of $n$ the exact maximum number of possible edges is known. For $n=2,3,4,\dots$ these numbers of edges are:

### Forbidden subgraphs

If a given graph $G$ is not a non-strict unit distance graph, neither is any supergraph $H$ of $G$. A similar idea works for strict unit distance graphs, but using the concept of an induced subgraph, a subgraph formed from all edges between the pairs of vertices in a given subset of vertices. If $G$ is not a strict unit distance graph, then neither is any other $H$ that has $G$ as an induced subgraph. Because of these relations between whether a subgraph or its supergraph is a unit distance graph, it is possible to describe unit distance graphs by their forbidden subgraphs. These are the minimal graphs that are not unit distance graphs of the given type. They can be used to determine whether a given graph $G$ is a unit distance graph, of either type. $G$ is a non-strict unit distance graph, if and only if $G$ is not a supergraph of a forbidden graph for the non-strict unit distance graphs. $G$ is a strict unit distance graph, if and only if $G$ is not an induced supergraph of a forbidden graph for the strict unit distance graphs.
For both the non-strict and strict unit distance graphs, the forbidden graphs include both the complete graph $K_{4}$ and the complete bipartite graph $K_{2,3}$. For $K_{2,3}$, wherever the vertices on the two-vertex side of this graph are placed, there are at most two positions at unit distance from them to place the other three vertices, so it is impossible to place all three vertices at distinct points. These are the only two forbidden graphs for the non-strict unit distance graphs on up to five vertices; there are six forbidden graphs on up to seven vertices and 74 on graphs up to nine vertices. Because gluing two unit distance graphs (or subgraphs thereof) at a vertex produce strict (respectively non-strict) unit distance graphs, every forbidden graph is a biconnected graph, one that cannot be formed by this gluing process.
The wheel graph $W_{7}$ can be realized as a strict unit distance graph with six of its vertices forming a unit regular hexagon and the seventh at the center of the hexagon. Removing one of the edges from the center vertex produces a subgraph that still has unit-length edges, but which is not a strict unit distance graph. The regular-hexagon placement of its vertices is the only one way (up to congruence) to place the vertices at distinct locations such that adjacent vertices are a unit distance apart, and this placement also puts the two endpoints of the missing edge at unit distance. Thus, it is a forbidden graph for the strict unit distance graphs, but not one of the six forbidden graphs for the non-strict unit distance graphs. Other examples of graphs that are non-strict unit distance graphs but not strict unit distance graphs include the graph formed by removing an outer edge from $W_{7}$, and the six-vertex graph formed from a triangular prism by removing an edge from one of its triangles.

### Algebraic numbers and rigidity

For every algebraic number $\alpha$, it is possible to construct a unit distance graph $G$ in which some pair of vertices are at distance $\alpha$ in all unit distance representations of $G$. This result implies a finite version of the Beckman–Quarles theorem: for any two points $p$ and $q$ at distance $\alpha$ from each other, there exists a finite rigid unit distance graph containing $p$ and $q$ such that any transformation of the plane that preserves the unit distances in this graph also preserves the distance between $p$ and $q$. The full Beckman–Quarles theorem states that the only transformations of the Euclidean plane (or a higher-dimensional Euclidean space) that preserve unit distances are the isometries. Equivalently, for the infinite unit distance graph generated by all the points in the plane, all graph automorphisms preserve all of the distances in the plane, not just the unit distances.
If $\alpha$ is an algebraic number of modulus 1 that is not a root of unity, then the integer combinations of powers of $\alpha$ form a finitely generated subgroup of the additive group of complex numbers whose unit distance graph has infinite degree. For instance, $\alpha$ can be chosen as one of the two complex roots of the polynomial $z^{4}-z^{3}-z^{2}-z+1$, producing an infinite-degree unit distance graph with four generators.

### Coloring

The Hadwiger–Nelson problem concerns the chromatic number of unit distance graphs, and more specifically of the infinite unit distance graph formed from all points of the Euclidean plane. By the de Bruijn–Erdős theorem, which assumes the axiom of choice, this is equivalent to asking for the largest chromatic number of a finite unit distance graph. There exist unit distance graphs requiring five colors in any proper coloring, and all unit distance graphs can be colored with at most seven colors.
Answering another question of Paul Erdős, it is possible for triangle-free unit distance graphs to require four colors.

### Enumeration

The number of strict unit distance graphs on $n\geq 4$ labeled vertices is at most ${\binom {n(n-1)}{2n}}=O\left(2^{{\bigl4+o(1){\bigr )}n\log _{2}n}\right),$ as expressed using big O notation and little o notation.

## Generalization to higher dimensions

The definition of a unit distance graph may naturally be generalized to any higher-dimensional Euclidean space. In three dimensions, unit distance graphs of $n$ points have at most $n^{3/2}\beta (n)$ edges, where $\beta$ is a very slowly growing function related to the inverse Ackermann function. This result leads to a similar bound on the number of edges of three-dimensional relative neighborhood graphs. In four or more dimensions, any complete bipartite graph is a unit distance graph, realized by placing the points on two perpendicular circles with a common center, so unit distance graphs can be dense graphs. The enumeration formulas for unit distance graphs generalize to higher dimensions, and shows that in dimensions four or more the number of strict unit distance graphs is much larger than the number of subgraphs of unit distance graphs.
Any finite graph may be embedded as a unit distance graph in a sufficiently high dimension. Some graphs may need very different dimensions for embeddings as non-strict unit distance graphs and as strict unit distance graphs. For instance the $2n$-vertex crown graph may be embedded in four dimensions as a non-strict unit distance graph (that is, so that all its edges have unit length). However, it requires at least $n-2$ dimensions to be embedded as a strict unit distance graph, so that its edges are the only unit-distance pairs. The dimension needed to realize any given graph as a strict unit graph is at most twice its maximum degree.

## Computational complexity

Constructing a unit distance graph from its points is an important step for other algorithms for finding congruent copies of some pattern in a larger point set. These algorithms use this construction to search for candidate positions where one of the distances in the pattern is present, and then use other methods to test the rest of the pattern for each candidate. A method of Matoušek (1993) can be applied to this problem, yielding an algorithm for finding a planar point set's unit distance graph in time $n^{4/3}2^{O(\log ^{*}n)}$ where $\log ^{*}$ is the slowly growing iterated logarithm function.
It is NP-hard—and more specifically, complete for the existential theory of the reals—to test whether a given graph is a (strict or non-strict) unit distance graph in the plane. It is also NP-complete to determine whether a planar unit distance graph has a Hamiltonian cycle, even when the graph's vertices all have known integer coordinates.