# Farthest-first traversal The first five steps of the farthest-first traversal of a planar point set. The first point is chosen arbitrarily and each successive point is as far as possible from all previously chosen points.

In computational geometry, the farthest-first traversal of a bounded metric space is a sequence of points in the space, where the first point is selected arbitrarily and each successive point is as far as possible from the set of previously-selected points. The same concept can also be applied to a finite set of geometric points, by restricting the selected points to belong to the set or equivalently by considering the finite metric space generated by these points. For a finite metric space or finite set of geometric points, the resulting sequence forms a permutation of the points, known as the greedy permutation.

Farthest-point traversals have many applications, including the approximation of the traveling salesman problem and the metric k-center problem. They may be constructed in polynomial time, or (for low-dimensional Euclidean spaces) approximated in near-linear time.

## Properties

Fix a number k, and consider the subset formed by the first k points of the farthest-first traversal of any metric space. Let r be the distance between the final point of the prefix and the set of previously-selected points. Then this subset has the following two properties:

• All pairs of the selected points are at distance at least r from each other, and
• All points of the whole metric space are at distance at most r from the subset.

In other words, each prefix of the farthest-first traversal forms a Delone set.

## Applications

The first use of the farthest-first traversal was by Rosenkrantz, Stearns & Lewis (1977) in connection with heuristics for the travelling salesman problem. In the farthest-insertion heuristic, discussed by Rosenkrantz et al., a tour is built up incrementally, by adding one point at a time in the ordering given by a farthest-first traversal. To add each point to the traveling salesman tour of the previous points, this heuristic considers all possible ways of breaking one edge of the tour and replacing it by two edges through the new point, and chooses the cheapest of these replacements. Although Rosenkrantz et al. prove only a logarithmic approximation ratio for this method, they show that in practice it often works better than other insertion methods with better provable approximation ratios.

Later, the same sequence of points was popularized by Gonzalez (1985), who used it as part of a greedy approximation algorithm for the problem of finding k clusters that minimize the maximum diameter of a cluster. The same algorithm applies also, with the same approximation quality, to the metric k-center problem. This problem is one of several formulations of cluster analysis and facility location, in which the goal is to partition a given set of points into k different clusters, each with a chosen center point, such that the maximum distance from any point to the center of its cluster is minimized. For instance, this problem can be used to model the placement of fire stations within a city, in order to ensure that every address within the city can be reached quickly by a fire truck. Gonzalez described a clustering heuristic that selects as centers the first k points of a farthest-first traversal, and then assigns each of the input points to its nearest center. If r is the distance from the set of k selected centers to the next point at position k + 1 in the traversal, then this clustering achieves a distance of r. However, the subset of k centers together with the next point are all at distance at least r from each other, and any k-clustering would put two of these points into one cluster, so there is no clustering with distance better than r/2. Thus, Gonzalez's heuristic gives an approximation ratio of 2 for this problem. This heuristic, and the name "farthest-first traversal", are often incorrectly attributed to a different paper from the same time, Hochbaum & Shmoys (1985). However, Hochbaum and Shmoys used graph-theoretic techniques, not the farthest-first traversal, to obtain a different approximation algorithm for the metric k-center with the same approximation ratio as Gonzalez's heuristic. For both the min-max diameter clustering problem and the metric k-center problem, these approximations are optimal: the existence of a polynomial-time heuristic with any constant approximation ratio less than 2 would imply that P = NP.

As well as for clustering, the farthest-first traversal can also be used in another type of facility location problem, the max-min facility dispersion problem, in which the goal is to choose the locations of k different facilities so that they are as far apart from each other as possible. More precisely, the goal in this problem is to choose k points from a given metric space or a given set of candidate points, in such a way as to maximize the minimum pairwise distance between the selected points. Again, this can be approximated by choosing the first k points of a farthest-first traversal. If r denotes the distance of the kth point from all previous points, then every point of the metric space or the candidate set is within distance r of the first k − 1 points. By the pigeonhole principle, some two points of the optimal solution (whatever it is) must both be within distance r of the same point among these first k − 1 chosen points, and (by the triangle inequality) within distance 2r of each other. Therefore, the heuristic solution given by the farthest-first traversal is within a factor of two of optimal.

Other applications of the farthest-first traversal include color quantization (clustering the colors in an image to a smaller set of representative colors), progressive scanning of images (choosing an order to display the pixels of an image so that prefixes of the ordering produce good lower-resolution versions of the whole image rather than filling in the image from top to bottom), point selection in the probabilistic roadmap method for motion planning, simplification of point clouds, generating masks for halftone images, hierarchical clustering, finding the similarities between polygon meshes of similar surfaces, underwater robot task planning, fault detection in sensor networks, modeling phylogenetic diversity, matching vehicles in a heterogenous fleet to customer delivery requests, uniform distribution of geodetic observatories on the Earth's surface or of other types of sensor network, generation of virtual point lights in the instant radiosity computer graphics rendering method, and geometric range searching data structures.

## Algorithms

The farthest-first traversal of a finite point set may be computed by a greedy algorithm that maintains the distance of each point from the previously selected points, performing the following steps:

• Initialize the sequence of selected points to the empty sequence, and the distances of each point to the selected points to infinity.
• While not all points have been selected, repeat the following steps:
• Scan the list of not-yet-selected points to find a point p that has the maximum distance from the selected points.
• Remove p from the not-yet-selected points and add it to the end of the sequence of selected points.
• For each remaining not-yet-selected point q, replace the distance stored for q by the minimum of its old value and the distance from p to q.

For a set of n points, this algorithm takes O(n2) steps and O(n2) distance computations. A faster approximation algorithm, given by Har-Peled & Mendel (2006), applies to any subset of points in a metric space with bounded doubling dimension, a class of spaces that include the Euclidean spaces of bounded dimension. Their algorithm finds a sequence of points in which each successive point has distance within a 1 − ε factor of the farthest distance from the previously-selected point, where ε can be chosen to be any positive number. It takes time O(n log n).

For selecting points from a continuous space such as the Euclidean plane, rather than a finite set of candidate points, these methods will not work directly, because there would be an infinite number of distances to maintain. Instead, each new point should be selected as the center of the largest empty circle defined by the previously-selected point set. This center will always lie on a vertex of the Voronoi diagram of the already selected points, or at a point where an edge of the Voronoi diagram crosses the domain boundary. In this formulation the method for constructing farthest-first traversals has also been called incremental Voronoi insertion. It is similar to Ruppert's algorithm for finite element mesh generation, but differs in the choice of which Voronoi vertex to insert at each step.