# Approximating the Fréchet Distance for Realistic Curves in Near Linear Time

- 442 Downloads
- 23 Citations

## Abstract

We present a simple and practical (1+*ε*)-approximation algorithm for the Fréchet distance between two polygonal curves in ℝ^{ d }. To analyze this algorithm we introduce a new realistic family of curves, *c*-packed curves, that is closed under simplification. We believe the notion of *c*-packed curves to be of independent interest. We show that our algorithm has near linear running time for *c*-packed polygonal curves, and similar results for other input models, such as low-density polygonal curves.

### Keywords

Frechet distance Approximation algorithms Realistic input models## 1 Introduction

Comparing geometric shapes is a task that arises in a wide arena of applications. The Fréchet distance and its variants have been used, to this end, to compare curves in applications such as dynamic time-warping [19], speech recognition [21], signature and handwriting recognition [22, 23], matching of time series in databases [20], as well as geographic applications, such as map-matching of vehicle tracking data [8, 24], and moving objects analysis [10, 11].

### Previous Results

For two polygonal curves of total complexity *n* in the plane, their Fréchet distance can be computed in *O*(*n* ^{2}log*n*) time [3], and their Hausdorff distance can be computed in *O*(*n*log*n*) time [2]. It has been an open problem to find a subquadratic algorithm for computing the Fréchet distance for two curves. For the problem of deciding whether the Fréchet distance between two curves is smaller or equal a given value a lower bound of *Ω*(*n*log*n*) was given by [9]. Recently, Alt [2] conjectured that the decision problem may be 3SUM-hard. The only subquadratic algorithms known are for quite restricted classes of curves such as for closed convex curves and for *κ*-bounded curves [4]. For a curve to be *κ*-bounded means, roughly, that for any two points on the curve the portion of the curve in between them cannot be further away from either point than *κ*/2 times the distance between the two points. For closed convex curves the Fréchet distance equals the Hausdorff distance and for *κ*-bounded curves the Fréchet distance is at most (1+*κ*) times the Hausdorff distance, and hence the *O*(*n*log*n*) algorithm for the Hausdorff distance applies.

Aronov et al. [6] provided a near linear time (1+*ε*)-approximation algorithm for the *discrete* Fréchet distance, which only considers distances between vertices of the curves. Their algorithm works for *backbone curves*, which are used to model protein backbones in molecular biology. Backbone curves are required to have, roughly, unit edge length and a minimal distance between any pair of vertices. They use curve simplification to speed up their algorithm. Agarwal et al. [1] studied fast simplification that preserves the Fréchet distance.

### The Input Model

We introduce a new class of curves, called *c*-packed curves, for which we can approximate the Fréchet distance quickly, given that the constant *c* is small. Intuitively, the constant *c* measures how “*unrealistic*” the input is. We compare this new input model to previous models such as *fatness* and *low density*, as well as *κ-boundedness*. These so-called *realistic input models* are commonly used for the analysis of problems where the worst case complexity is dominated by degenerate or contrived configurations which are highly unlikely to occur in practice, see [15] for an overview.

A curve *π* is *c-packed* if the total length of *π* inside any ball is bounded by *c* times the radius of the ball. A *κ*-bounded curve might have arbitrary length while maintaining a finite diameter, and as such may not be *c*-packed, see Sect. 4.3. But unlike *κ*-bounded curves, the Fréchet distance between two *c*-packed curves might be arbitrarily larger than their Hausdorff distance. Indeed, *c*-packed curves are considerably more general and a more natural family of curves. For example, a *c*-packed curve might self cross and revisit the same location several times, and the class of *c*-packed curves is closed under concatenation, none of which is true for *κ*-bounded curves. Intuitively, *c*-packed curves behave reasonably in any resolution.

*c*-packed curves. The boundary of convex polygons, algebraic curves of bounded maximum degree, the boundary of (

*α*,

*β*)-covered shapes [17], and the boundary of

*γ*-fat shapes [14] are all

*c*-packed. Indeed, the boundaries of (

*α*,

*β*)-covered shapes and

*γ*-fat shapes are assumed to be formed by a constant number of algebraic curves of bounded maximum degree. If one removes the requirement that a

*γ*-fat curve be of bounded descriptive complexity, then also fractal curves, like Koch’s snowflake, which can have infinite length within a bounded area, can be fat [7]. Naturally, these curves cannot be

*c*-packed. Interestingly, one can show that (

*α*,

*β*)-covered polygons are

*c*-packed even if they have unbounded complexity, see Appendix A and also the result of Bose et al. [7].

It is easy to verify that *c*-packed curves are also low density [15], but a low-density curve might not be *c*-packed, for any bounded *c*, see Sect. 4.2. However, the class of *c*-packed curves is closed under simplification, see Lemma 4.3, and this is not true for low-density curves.

### Our Results

We present a new algorithm for computing a (1+*ε*)-approximation of the Fréchet distance for polygonal curves in ℝ^{ d }. Underlying the algorithm are several new insights. First, we use the idea of curve simplification to reduce the complexity of the free space diagram, as this simplification results in a contraction of the corresponding rows or columns in the free space diagram. We introduce the notion of *relative free space complexity* in Definition 3.3 to capture the complexity of the free space diagram of two curves, which are simplified to the appropriate resolution. Surprisingly, without simplification, almost any two curves from natural families of curves can have a free space diagram for the value realizing the Fréchet distance that has quadratic complexity (even in the plane). Secondly, we present an efficient construction algorithm for this reduced size free space diagram that enables us to solve the decision problem in linear time in the relative free space complexity of the curves. Thirdly, we prove that monotonicity events are sufficiently close to vertex–edge events or an approximate distance between two vertices of the curves. Therefore, the search for the Fréchet distance can be done efficiently without using parametric search or random sampling, by using approximate distance selection. Carefully combining these insights yields the new algorithm, which has running time near linear in the relative free space complexity of the input curves.

In the second part of the paper, we analyze the relative free space complexity for various families of curves. We prove that *c*-packed curves have linear relative free space complexity for fixed *c* and *ε*. We next prove a subquadratic bound on the relative complexity of the free space of low-density curves. This relies on a new packing lemma showing that, if the simplification of a low-density curve is long inside a relatively small area, then the original curve must contain many vertices in the vicinity of this region. We also prove that the relative free space complexity of *κ*-bounded curves is linear for a fixed *κ*, which leads to an improvement of the result by Alt et al. [4].

Summary of new results for computing a (1+*ε*)-approximation to the Fréchet distance between two curves *π* and *σ* with *n* vertices in ℝ^{ d }

Curves type | Running time | See |
---|---|---|

| \(\displaystyle O( c n /{\varepsilon}+ cn \log n)\) | Theorem 4.5 |

| Same as 2 | Lemma 4.16 |

| \(\displaystyle O{ \bigl( (\kappa/{\varepsilon})^d n + \kappa^d n \log n \bigr)}\) | Theorem 4.20 |

| \(\displaystyle O { \biggl( \frac{n^{2(d-1)/d}}{{\varepsilon}^2} + n^{2(d-1)/d}\log n \biggr)}\) | Theorem 4.14 |

| \(\displaystyle O{ \bigl( c^2 n/{\varepsilon}^2 + c^2 n \log n \bigr)}\) | Theorem 5.5 |

### Organization

In Sect. 2, we provide some background on the Fréchet distance and the notion of the free space diagram. In Sect. 3, we describe the approximation algorithm that uses simplification. To this end, we show in Sect. 3.1 that it suffices to only compute the reachable parts of the free space diagram and in Sect. 3.2 we present a fuzzy decider procedure and show how it can be used to make exact decisions during a binary search for the Fréchet distance. In Sect. 3.3, we deal with the different subroutines used in the search for the Fréchet distance and in Sect. 3.4 we give the resulting general algorithm and analyze its correctness and running time, which is near linear in the relative free space complexity. In Sect. 4, we bound the relative free space complexity of various families of curves. In particular, in Sect. 4.1, we introduce the notion of *c*-packed curves, and study their behavior under simplification. In Sect. 4.3, we bound the relative free space complexity of *κ*-bounded curves, and in Sect. 4.2 we handle low-density curves. In Sect. 5, we extend the algorithm to closed curves. We conclude with discussion in Sect. 6.

## 2 Preliminaries

### 2.1 Notations and Definitions

Let *π* be a curve in ℝ^{ d }; that is, a continuous mapping from [0,1] to ℝ^{ d }. In the following, we will identify *π* with its range *π*([0,1])⊆ℝ^{ d } if it is clear from the context. The curve *π* is *closed* if *π*(0)=*π*(1). We use ∥⋅∥ to denote the Euclidean distance as well as the length of a curve. For a polygonal curve *π*, let *V*(*π*) denote the set of vertices of *π*. For two points *p* and *q* on a curve *π*, let *π*[*p*,*q*] denote the portion of the curve between the two points.

We denote with *B*(*p*,*r*) the ball of radius *r* centered at *p*, and *S*(*p*,*r*) denotes the corresponding sphere. Given a set of numbers *U*⊆ℝ, an *atomic interval* of *U* is a (possibly infinite) maximal interval on the real line that does not contain any point of *U* in its interior. Let Open image in new window be the set of all pairwise distances of points in P.

### 2.2 Fréchet Distance and the Free Space Diagram

*reparameterization*is a bijective and continuous function

*f*:[0,1]→[0,1]. It is

*orientation-preserving*if

*f*(0)=0 and

*f*(1)=1. Given two reparameterizations

*f*and

*g*for two curves

*π*and

*σ*, respectively, define their

*width*as This can be interpreted as the maximum length of a leash one needs to walk a dog, where the dog walks monotonically along

*π*according to

*f*, while the handler walks monotonically along

*σ*according to

*g*. In this analogy, the Fréchet distance is the shortest possible leash admitting such a walk.

*π*and

*σ*in ℝ

^{ d }, the

*Fréchet distance*between them is where

*f*and

*g*are orientation-preserving reparameterizations of the curves

*π*and

*σ*, respectively. The Fréchet distance complies with the triangle inequality; that is, for any three curves

*π*,

*σ*and

*τ*we have Open image in new window .

*π*,

*σ*be curves and

*δ*>0 a parameter, the

*free space*of

*π*and

*σ*of radius

*δ*is defined as We are interested only in polygonal curves. Then the square [0,1]

^{2}can be broken into a (not necessarily uniform) grid called the

*free space diagram*, where a vertical line corresponds to a vertex of

*π*and a horizontal line corresponds to a vertex of

*σ*. Every two segments of

*π*and

*σ*define a

*free space cell*in this grid. In particular, let

*C*

_{ i,j }=

*C*

_{ i,j }(

*π*,

*σ*) denote the free space cell that corresponds to the

*i*th edge of

*π*and the

*j*th edge of

*σ*. The cell

*C*

_{ i,j }is located in the

*i*th column and

*j*th row of this grid.

*δ*, inside such a cell

*C*

_{ i,j }(i.e.,

*D*

_{≤δ }(

*π*,

*σ*)∩

*C*

_{ i,j }) is the clipping of an affine transformation of a disk to the cell [3], see the figure below; as such, it is convex and of constant complexity. Let \(I^{h}_{i,j}\) denote the horizontal

*free space interval*at the top boundary of

*C*

_{ i,j }, and \(I^{v}_{i,j}\) denote the vertical free space interval at the right boundary.

The Fréchet distance between *π* and *σ* is at most *δ* if and only if there is an (*x*,*y*)-monotone path in the free space diagram between (0,0) and (1,1) that is fully contained in *D* _{≤δ }(*π*,*σ*). Let the *reachability intervals* \(R^{h}_{i,j}\subseteq I^{h}_{i,j}\) and \(R^{v}_{i,j}\subseteq I^{v}_{i,j}\) consist of the points (*x*,*y*) on the boundary that are reachable by a monotone path from (0,0) to (*x*,*y*).

Such a path to (1,1) can be computed, if it exists, in *O*(*n* ^{2}) time by dynamic programming, where *n* is the total complexity of the two polygonal curves *π* and *σ*, see [3].

#### 2.2.1 Free Space Events

To compute the Fréchet distance consider increasing *δ* from 0 to ∞. As *δ* increases, structural changes to the free space happen. We are interested in the radii (i.e., the value of *δ*) of these events.

*π*and a vertex

*p*of

*σ*, a

*vertex–edge event*corresponds to the minimum value

*δ*such that u is tangent to

*B*(

*p*,

*δ*). In the free space diagram, this corresponds to the event that a free space interval that consists of only one point was just created. The line supporting this boundary edge corresponds to the vertex, and the other dimension corresponds to the edge. Naturally, the event could happen at a vertex of u.

*monotonicity event*, corresponds to a value

*δ*for which a monotone subpath inside

*D*

_{≤δ }becomes feasible, see Fig. 1. Geometrically, this corresponds to two vertices

*p*and

*q*on one curve and a directed segment u on the other curve such that: (1) u passes through the intersection

*S*(

*p*,

*δ*)∩

*S*(

*q*,

*δ*), and (2) u intersects

*B*(

*q*,

*δ*) first and

*B*(

*p*,

*δ*) second, where

*p*comes before

*q*in the order along the curve

*π*.

Other values of *δ* that would be relevant to our algorithm are the distances between any pair of points of *V*(*π*)∪*V*(*σ*). Technically, apart from the two single events that the endpoints of the curves are being matched to each other, these *vertex–vertex* events are vertex–edge events when they are relevant, but they will be handled naturally by our algorithm.

### 2.3 Curve Simplification

We suggest a straightforward greedy algorithm for curve simplification, which is sufficient for our purposes. We comment that Agarwal et al. [1] suggested a more aggressive (but slightly slower and more complicated) simplification algorithm that can be used instead.

### Algorithm 2.1

Given a polygonal curve *π*=*p* _{1} *p* _{2} *p* _{3}…*p* _{ k } and a parameter *μ*>0, consider the following simplification algorithm: First mark the initial vertex *p* _{1} and set it as the current vertex. Now scan the polygonal curve from the current vertex until it reaches the first vertex *p* _{ i } that is in distance at least *μ* from the current vertex. Mark *p* _{ i } and set it as the current vertex. Repeat this until reaching the final vertex of the curve, and also mark this final vertex. Consider the curve that connects only the marked vertices, in their order along *π*. We refer to the resulting curve *π*′=simpl(*π*,*μ*) as the *μ-simplification* of *π*. Note that this simplification can be computed in linear time.

### Remark 2.2

The simplified curve has the useful property that all its segments are of length at least *μ*, except for the last edge that might be shorter. For the sake of simplicity of exposition, we assume that the last segment in the simplified curve also has length at least *μ*. Our arguments can be easily modified to handle this more general case.

### Lemma 2.3

*For any polygonal curve* *π* *in* ℝ^{ d }, *and* *μ*≥0, *it holds* Open image in new window .

### Proof

*π*,

*μ*) and the portion \(\widehat{\pi}\) of

*π*that corresponds to it. Clearly, all the vertices of \(\widehat{\pi}\) are contained inside a ball of radius

*μ*centered at the first endpoint of u visited by

*π*, except the last vertex of \(\widehat{\pi}\). As such, one can parameterize u and \(\widehat{\pi}\), such that initially the point stays on the vertex of u while visiting all vertices of \(\widehat{\pi}\) (except the last one), and then simultaneously move in sync on u and the last segment of \(\widehat{\pi}\), in such a way that the distance is always at most

*μ*. □

## 3 The Approximation Algorithm

### 3.1 Computing the Reachable Free Space

For two curves *π* and *σ*, their *reachable free space*, denoted by Open image in new window , is the set of all the points of *D* _{≤δ }(*π*,*σ*) that are reachable from (0,0) by an (*x*,*y*)-*monotone* path.

The set Open image in new window has finite descriptive complexity inside each grid cell, and we need to describe it only for the grid cells that have non-empty intersection with Open image in new window . Clearly, generating only those grid cells is sufficient to decide if there is a monotone path between (0,0) and (1,1), which is equivalent to deciding if the Fréchet distance between *π* and *σ* is smaller or equal to *δ*. In particular, to fully describe Open image in new window , we will specify the reachability intervals \(R^{h}_{i,j}\subseteq I^{h}_{i,j}\) and \(R^{v}_{i,j}\subseteq I^{v}_{i,j}\) for each cell *C* _{ i,j }, which describe the intersection of Open image in new window with the top and right boundary of *C* _{ i,j }. These intervals contain all the needed information, since Open image in new window is convex.

The *complexity* of the reachable free space, for distance *δ*, denoted by *N* _{≤δ }(*π*,*σ*), is the total number of grid cells which have non-empty intersection with Open image in new window . One can compute this set of cells and extract an existing monotone path in *O*(*N* _{≤δ }(*π*,*σ*)) time, by performing a bfs of the grid cells that visits only the reachable cells. This yields the following relatively easy result. We include the details both for the sake of completeness and because the algorithm we suggest is engagingly simple.

### Lemma 3.1

*Given two polygonal curves* *π* *and* *σ* *in* ℝ^{ d }, *and a parameter* *δ*≥0, *one can compute a representation of* Open image in new window *in* *O*(*N* _{≤δ }(*π*,*σ*)) *time*. *Furthermore*, *one can decide if* Open image in new window , *and if this is the case also extract reparameterizations in* *O*(*N* _{≤δ }(*π*,*σ*)) *time*.

### Proof

We create a directed graph *G* that has a node *v*(*i*,*j*) for every reachable free space cell *C* _{ i,j }. With each node *v*(*i*,*j*) we store the free space intervals \(I^{h}_{i,j}\) and \(I^{v}_{i,j}\) as well as the reachability intervals \(R^{h}_{i,j}\subseteq I^{h}_{i,j}\) and \(R^{v}_{i,j}\subseteq I^{v}_{i,j}\).

Each node *v*(*i*,*j*) can have an outgoing edge to its right and top neighbor; an edge between these vertices exists if and only if the corresponding reachability interval between them is nonempty. In particular, a monotone path from (0,0) to a point (*x*,*y*)∈*C* _{ i,j } in Open image in new window corresponds to a monotone path in the graph *G* from *v*(1,1) to *v*(*i*,*j*). Furthermore, any such monotone path has exactly *k*=*i*+*j*−2 edges on it.

We compute the graph *G* on the fly by performing a bfs on it, starting from *v*(1,1), and keeping the invariant that when the bfs visits a node *v*(*i*,*j*) it enqueues the vertices *v*(*i*,*j*+1) and *v*(*i*+1,*j*), in this order, to the bfs queue (if they are connected to *v*(*i*,*j*), naturally).

*k*, the bfs queue contains the nodes on the

*k*th diagonal (i.e., all nodes

*v*(

*i*,

*j*) such that

*i*+

*j*=

*k*−1) of the diagram sorted from left to right. However, the same node might appear twice (consecutively) in this queue.

In every iteration, the bfs dequeues the one or two copies of the same node *v*(*i*,*j*) and merges the two copies of the same vertex into one if necessary. Now, the one or two vertices (i.e., *v*(*i*−1,*j*) and *v*(*i*,*j*−1)) that have incoming edges to *v*(*i*,*j*) are known, as are their reachability intervals. Therefore one can compute the reachability intervals for *v*(*i*,*j*) in constant time. Now, *v*(*i*,*j*+1) is enqueued if and only if the top side of the cell *C* _{ i,j } is reachable by a monotone path (i.e., \(R^{h}_{i,j}\neq\emptyset\)), and *v*(*i*+1,*j*) is enqueued if and only if the right side of the cell *C* _{ i,j } is reachable by a monotone path (i.e., \(R^{v}_{i,j}\neq\emptyset\)). Since Open image in new window is convex and of constant complexity, this can be done in constant time.

Clearly, the bfs takes time linear in the size of *G* and it computes the reachability information for all reachable free space cells of Open image in new window . Now, one can check if (1,1) is reachable by inspecting the reachability intervals for \(C_{\mathsf{n}_{\pi}-1 ,\mathsf{n}_{\sigma}-1}\), and checking if the top right corner of this cell is monotonically reachable from the origin, where n _{ π } is the number of vertices of the curve *π*. The monotone path realizing this can be extracted in linear time, by introducing backward edges in the graph and tracing a path back to the origin. □

### Observation 3.2

One can compute all relevant vertex–edge events with radius ≤*δ* in *O*(*N* _{≤δ }(*π*,*σ*)) time as follows. We compute the graph representation of Open image in new window using Lemma 3.1. Next, for each reachable cell consider the vertex–edge events at its top and right boundaries and compute their event radii. Recall that a cell boundary corresponds to an edge from the one curve and a vertex from the other curve. Clearly, any cell boundary can be used by the reparameterization of width ≤*δ*, if and only if the corresponding event radius is smaller or equal *δ*.

### 3.2 The Approximate Decision Procedure

In the following, we are interested in the maximum complexity of the reachable free space when considering any radius *δ* and simplifying the curves with radius *εδ*. The reasons will become apparent only shortly after, in Lemma 3.5 and Lemma 3.6, where we show that the simplification radius chosen this way enables us to either (i) compute a (1+*ε*)-approximation of the Fréchet distance, or (ii) solve the decision problem exactly using the simplified curves (see Sect. 3.3.5).

*ε*-fraction of the radius we care about (i.e.,

*δ*), and we then use the exact decision procedure on these two simplified curves. Since the Fréchet distance complies with the triangle inequality and by Lemma 2.3, we can infer the original distance from this information. In order for this approach to work, the complexity of the reachable free space for the two simplified curves has to be small. This notion of complexity is captured by the following definition.

### Definition 3.3

*π*and

*σ*, let be the maximum complexity of the reachable free space for the simplified curves. We refer to N(

*ε*,

*π*,

*σ*) as the

*ε-relative free space complexity*of

*π*and

*σ*. In order to give a more informative analysis, we will express the asymptotic time complexity of our algorithms not in terms of the size of the input, but instead use the size of the input and the free space complexity of the input as parameters.

*ε*<1 the following properties hold for N(⋅,⋅,⋅).

- (P1)
For any constant

*c*′≥1, it holds N(*ε*/*c*′,*π*,*σ*)=*O*(N(*ε*,*π*,*σ*)). - (P2)
N(

*ε*,*π*,*σ*)≤N(*ε*/2,*π*,*σ*)/2.

The above properties will hold for all the families of curves we consider. In Sect. 4.1 we show that N(*ε*,*π*,*σ*) is a linear function in the number of vertices of the two curves for a fixed *ε*>0 if the curves are sufficiently well-behaved (see for example Lemma 4.4). Combining this analysis with the time complexity analysis of the algorithms will yield near linear upper bounds on the running times of these algorithms for the classes of curves considered.

### Remark 3.4

In the following, when we state the time complexity of our algorithms, we always assume that N(*ε*,*π*,*σ*)=*Ω*(*n*), where *n* is the total number of vertices of *π* and *σ*.

### Lemma 3.5

*Let*

*π*

*and*

*σ*

*be polygonal curves in*ℝ

^{ d },

*and let*

*ε*>0

*and*

*δ*>0

*be two parameters*.

*Then*,

*the algorithm described below output*,

*in*

*O*(N(

*ε*,

*π*,

*σ*))

*time*,

*one of the following*:

- (A)
*“*Open image in new window*”*,*and reparameterizations of**π**and**σ**of width*≤(1+*ε*)*δ*,*and this happens if*Open image in new window . - (B)
- (C)
*If*Open image in new window*then the algorithm outputs either of the above outcomes*.

*In either case*,

*the statement returned is correct*.

### Proof

*μ*=(

*ε*/4)

*δ*. Compute in linear time the curves

*π*′=simpl(

*π*,

*μ*) and

*σ*′=simpl(

*σ*,

*μ*) using Algorithm 2.1. Let

*δ*′=

*δ*+2

*μ*and observe that

*μ*/

*δ*′=

*ε*/(4+2

*ε*). Using Lemma 3.1 we can decide whether Open image in new window in time, by assumption (P1). If so, we output the reparameterizations as a proof that

#### 3.2.1 How to Use the Approximate Decider in a Binary Search

In order to use Lemma 3.5 to perform a binary search for the Fréchet distance, we can turn the “fuzzy” decision procedure into a precise one as follows.

### Lemma 3.6

*Let* *π* *and* *σ* *be two polygonal curves in* ℝ^{ d }, *and let* 1≥*ε*>0 *and* *δ*>0 *be two parameters*. *Then*, *there is an algorithm* **decider**(*π*,*σ*,*δ*,*ε*) *that*, *in* *O*(N(*ε*,*π*,*σ*)) *time*, *returns one of the following outputs*: (i)* a* (1+*ε*)-*approximation to* Open image in new window , (ii) Open image in new window , *or* (iii) Open image in new window . *The answer returned is correct*.

### Proof

Let *δ*′=*δ*/(1+*ε*′), for *ε*′=*cε*, *c*=1/3. We run the algorithm of Lemma 3.5 with parameters *δ* and *ε*′. If the call returns “ Open image in new window ”, then we return this result.

Otherwise, we call Lemma 3.5 with parameters *δ*′ and *ε*′. If it returns that “ Open image in new window ” then Open image in new window , and we return this result.

The only remaining possibility is that the two calls returned “ Open image in new window ” and “ Open image in new window ”. But then we have found the required approximation. Therefore, the resulting approximation factor of the reparameterizations returned by the call with *δ* is \(\leq\frac{(1+{\varepsilon}') \delta}{\delta'}= (1+ c{\varepsilon})^{2} < (1+{\varepsilon})\) as can be easily verified, since 0<*ε*≤1. □

### 3.3 Searching for the Fréchet Distance

#### 3.3.1 Searching in a Fixed Interval

It is now straightforward to perform a binary search on an interval [*α*,*β*] to approximate the value of the Fréchet distance, if it falls inside this interval. Indeed, partition this interval into subintervals of length *εα* and perform a binary search to find the interval that contains the Fréchet distance. There are *O*(*β*/*εα*) intervals, and this would require *O*(log(*β*/*εα*)) calls to **decider**. By using exponential subintervals, one can do slightly better, as testified by the following lemma.

### Lemma 3.7

*Given two curves* *π* *and* *σ* *in* ℝ^{ d }, *a parameter* 1≥*ε*>0, *and an interval* [*α*,*β*], *one can perform a binary search in* [*α*,*β*] *and obtain a* (1+*ε*)-*approximation to* Open image in new window *if* Open image in new window , *or report that* Open image in new window . *The algorithm*, *denoted by* **search Interval**(*π*,*σ*,[*α*,*β*],*ε*), *takes* \(O{ ( \log\frac{\log (\beta/\alpha)}{{\varepsilon}} )}\) *calls to* **decider**.

### Proof

Let *α* _{ i }=*α*(1+*ε*)^{ i } for *i*=0,…,*M*=⌊log_{1+ε }(*β*/*α*)⌋ and *α* _{ M+1}=*β*. Perform a binary search, using **decider**(*π*,*σ*,*δ*,*ε*) to find the two values *α* _{ i } and *α* _{ i+1} such that Open image in new window . Since *α* _{ i+1}=(1+*ε*)*α* _{ i }, we conclude that we found the required approximation.

It might be that during this procedure one of the calls to **decider**(*π*,*σ*,*δ*,*ε*) found the required approximation, and in this case we abort the binary search and just return this approximation.

*O*(log

*M*)=

*O*(loglog

_{1+ε }(

*β*/

*α*)) calls to

**decider**. Observe that Indeed,

*e*

^{ x/2}≤1+

*x*≤

*e*

^{ x }for

*x*∈[0,1], and this implies that

*x*/2≤ln(1+

*x*)≤

*x*, which is the inequality used above. □

#### 3.3.2 Searching over Events

Clearly, the procedure **searchInterval**(*π*,*σ*,[*α*,*β*],*ε*) alone does not suffice to solve our main problem, since the interval of distances we are searching over might have arbitrarily large “spread” (i.e., log*β*/*α* might be arbitrarily large). However, the Fréchet distance must be sufficiently close to a free space event in one of the “approximate” diagrams, i.e., a free space diagram of the two simplified curves. Thus, we can identify two kinds of critical value to search over, which are candidate values for the approximate Fréchet distance. These are the events where (i) the simplification of an input curve changes, or (ii) the reachability within the approximate free space diagram changes (i.e., a free space event; see Sect. 2.2.1).

The traditional solution to overcome this problem is to use parametric search. However, in our case, since we are only interested in approximation, we can use a simpler, “approximate”, search. It is sufficient to search over a set of values which approximate the event values by a constant factor, since we will use Lemma 3.7 to refine the resulting search interval in the main algorithm. Note, for instance, that we can easily use this lemma to turn a constant factor approximation of the Fréchet distance into a (1+*ε*)-approximation.

### Algorithm 3.8

Let **searchEvents**(*π*,*σ*,*Z*) denote the algorithm that performs a binary search over the values of *Z*, to compute the atomic interval of *Z* that contains the Fréchet distance between *π* and *σ*. This procedure uses **decider** (Lemma 3.6) to perform the decisions during the search.

#### 3.3.3 Searching over Simplifications

Consider the events when the simplified curves change, see Algorithm 2.1. Consider the set of all pairwise distances between vertices of *π* and *σ*. Observe that it breaks the real line into \(\binom{n}{2} + 1\) atomic intervals, such that in each such interval the simplification does not change. Thus simpl(*π*,*μ*) (resp. simpl(*σ*,*μ*)) might result in *O*(*n* ^{2}) different curves depending on the value of *μ*, where *n* is the total number of vertices of *π* and *σ*. As a first step we would therefore like to use Algorithm 3.8 to perform a binary search over those distances to find the atomic interval that contains the required Fréchet distance. Naively, this would require us to perform distance selection. However, it is believed that exact distance selection requires *Ω*(*n* ^{4/3}) time in the worst case [18]. To overcome this we will perform an approximate distance selection, as suggested by Aronov et al. [6].

### Lemma 3.9

*Given a set* P *of* *n* *points in* ℝ^{ d }. *Then*, *one can compute in* *O*(*n*log*n*) *time a set* *Z* *of* *O*(*n*) *numbers*, *such that for any* Open image in new window , *there exist numbers x*, *x*′∈*Z* *such that* *x*≤*y*≤*x*′≤2*x*. *Let* **approxDistances**(P) *denote this algorithm*.

### Proof

Compute an 8-well-separated pairs decomposition of P. Using the algorithm of Callahan and Kosaraju [12] this can be done in *O*(*n*log*n*) time, and results in a set of pairs of subsets {(*X* _{1},*Y* _{1}),…,(*X* _{ m },*Y* _{ m })}, where *m*=*O*(*n*), such that for any two points *p*,*q*∈P there exists a pair (*X* _{ i },*Y* _{ i }) in the above decomposition, such that: (i) *p*∈*X* _{ i } and *q*∈*Y* _{ i } (or vice versa), and (ii) \(\max(\mathrm{d{}i{}am} ( {X_{i}} ), \mathrm {d{}i{}am} ( {Y_{i}} )) \leq \min_{p_{i} \in X_{i},q_{i} \in Y_{i}}\Vert {p_{i} - q_{i}} \Vert/8\).

This implies that the distance of any pair of points in *X* _{ i } and *Y* _{ i }, respectively, are the same up to a small constant. As such, for every pair (*X* _{ i },*Y* _{ i }), for *i*=1,…,*m*, we pick representative points *p* _{ i }∈*X* _{ i } and *q* _{ i }∈*Y* _{ i }, and set *ℓ* _{ i }=(3/4)∥*p* _{ i }−*q* _{ i }∥. Let *Z*={*ℓ* _{1},…,*ℓ* _{ m },2*ℓ* _{1},…,2*ℓ* _{ m }} be the computed set of values.

Consider any pair of points *p*,*q*∈P. For the specific pair (*X* _{ i },*Y* _{ i }) that contains the pair of points *p* and *q* that we are interested in, we have *ℓ* _{ i }=(3/4)∥*p* _{ i }−*q* _{ i }∥≤∥*p* _{ i }−*q* _{ i }∥−diam(*X* _{ i })−diam(*Y* _{ i })≤∥*p*−*q*∥≤∥*p* _{ i }−*q* _{ i }∥+diam(*X* _{ i })+diam(*Y* _{ i })≤(5/4)∥*p* _{ i }−*q* _{ i }∥≤2*ℓ* _{ i }, thus establishing the claim. □

#### 3.3.4 Monotonicity Events

The following lemma testifies that the radius of a monotonicity event must be “close” to either a vertex–edge event or to the distance between two vertices. Since we will approximate the vertex–vertex distances and perform a binary search over them, this implies that we further only need to consider vertex–edge events. Furthermore, by Observation 3.2, the number of those vertex–edge events which remain in the resulting search range can be bounded by the complexity of the reachable free space.

### Lemma 3.10

*Let* *x* *be the radius of a monotonicity event involving vertices* *p*,*q* *and a segment* u. *Then there exists a number* *y* *such that* *y*/2≤*x*≤3*y*, *and* *y* *is either in* Open image in new window *or* *y* *is the radius of a vertex–edge event*.

### Proof

Let *s* be the intersection point of *S*(*p*,*x*)∩*S*(*q*,*x*) which lies on u. Let *p*′ (resp. *q*′) be the closest point on u to *p* (resp. *q*).

Clearly ∥*p*′−*q*′∥≤∥*p*−*q*∥ (since the projection onto the nearest neighbor of a convex set is a contraction), and since *p*′∈*B*(*p*,*x*) and *q*′∈*B*(*q*,*x*), the point *s* lies on the segment *p*′*q*′.

*x*=∥

*p*−

*s*∥≤∥

*p*−

*p*′∥+∥

*p*′−

*s*∥≤∥

*p*−

*p*′∥+∥

*p*′−

*q*′∥≤∥

*p*−

*p*′∥+∥

*p*−

*q*∥, by the triangle inequality.

If ∥*p*−*p*′∥≥2∥*p*−*q*∥ then the above implies that *x*∈[1/2,3/2]∥*p*−*p*′∥. If *p*′ is an endpoint of u then ∥*p*−*p*′∥ is in \(\mathcal{W}\). Otherwise, ∥*p*−*p*′∥ is the radius of the vertex–edge event between *p* and u. In either case, this implies the claim.

If ∥*p*−*p*′∥≤2∥*p*−*q*∥ then *x*=∥*p*−*s*∥≤∥*p*−*p*′∥+∥*p*−*q*∥≤2∥*p*−*q*∥+∥*p*−*q*∥=3∥*p*−*q*∥, and of course \(\Vert {p- q} \Vert \in \mathcal{W}\). Now, the two balls of radius *x* centered at *p* and *q*, respectively, cover the segment *pq*, and we have ∥*p*−*q*∥/2≤*x*, which implies the claim. □

#### 3.3.5 Searching with a Fixed Simplification

Assume that we have found simplifications *τ* and *η*, such that the Fréchet distance of those curves yields the desired (1+*ε*)-approximation. Clearly, an approximation of Open image in new window suffices for our result. To this end, let **searchIntervalNoSimp**(*π*,*σ*,[*α*,*β*],*ε*) be the variant of **searchInterval** from Lemma 3.7 that uses Lemma 3.1 directly instead of calling **decider**. This version searches for the Fréchet distance in the given interval, but does not perform simplification before calling the decision procedure. It returns a (1+*ε*)-approximation of the Fréchet distance, given that it is contained in this interval. Note that correctness and running time of Lemma 3.7 are not affected by this modification.

### Lemma 3.11

*Let* *τ* *and* *η* *be two given curves in* ℝ^{ d }, *with total complexity* *n*, *and let* [*h* ^{−},*h* ^{+}] *be an interval*, *such that* (i) Open image in new window , *and* (ii)* there is no value of* Open image in new window *in the interval* [*h* ^{−},*h* ^{+}]. *Then*, *for* *ε*>0, *one can* (1+*ε*)-*approximate* Open image in new window *and compute reparameterizations in* *O*((*n*+*N*)log(*N*/*ε*)) *time*, *where* \(N =N_{\leq h^{+}}(\tau,\eta)\).

*Let* **aprxFréchetNoSimp**(*τ*,*η*,[*h* ^{−},*h* ^{+}],*ε*) *denote this algorithm*.

### Proof

For two real numbers *x*,*y*>0, we define [*x*/*y*]=max(*x*,*y*)/min(*x*,*y*).

Compute Open image in new window , using Lemma 3.1. Next, using Observation 3.2, compute from Open image in new window the set *Z* of all the radii of the vertex–edge events of *τ* and *η* with radius at most *h* ^{+}. Next, we sort *Z*, and perform a binary search over *Z*, using Lemma 3.1, for the atomic interval \(\mathcal{I}=[\alpha,\beta]\) of *Z* that contains the Fréchet distance Open image in new window . Next, call **searchIntervalNoSimp**(*τ*,*η*,[*α*,4*α*],*ε*) and **searchIntervalNoSimp**(*τ*,*η*,[*β*/4,*β*],*ε*). We claim that one of these two searches performed on the respective intervals will discover two consecutive values *x* and (1+*ε*)*x*, such that the two corresponding calls to the algorithm of Lemma 3.7 imply that Open image in new window .

Indeed, the interior of [*α*,*β*] does not contain any value in \(\mathcal{W}\) or a radius of a vertex–edge event of *τ* and *η*. Therefore, the interval [*α*,*β*] might contain only monotonicity events of *τ* and *η*. By Lemma 3.10, for a monotonicity event with radius r there exists a \(y \in Z\cup\mathcal{W}\), such that [r/*y*]≤3. But since there is no value of \(Z\cup\mathcal{W}\) in the interior of [*α*,*β*], and therefore, for any r″∈[4*α*,*β*/4] and \(y''\in Z\cup\mathcal{W}\), we have [r″/*y*″]≥4.

We conclude that no monotonicity event, vertex–edge event, or value of \(\mathcal{W}\) lies in the interval [4*α*,*β*/4]. Since the Fréchet distance must be equal to one such value, it follows that Open image in new window , but this implies that either Open image in new window or Open image in new window . In either case, the above algorithm would have found the approximate distance.

Computing and sorting the set of vertex–edge events takes *O*(*N*log*N*) time by Observation 3.2. The binary search requires *O*(log|*Z*|) calls to the algorithm of Lemma 3.1. The two calls to **searchIntervalNoSimp** require *O*(log(1/*ε*)) calls to Lemma 3.1. Now, observe that all these calls to the algorithm of Lemma 3.1 are done with values of *δ*≤*h* ^{+}. Thus the complexity of the reachable free space is bounded (up to a constant factor) by the number of vertex–edge events of values ≤*h* ^{+}, and this number is bounded by |*Z*|. Therefore, a call to Lemma 3.1 takes *O*(|*Z*|) time. Thus, the overall running time is *O*((*n*+|*Z*|)log(|*Z*|/*ε*)), and by definition \(\lvert Z\rvert= O{ ( N_{\leq h^{+}}(\tau,\eta ) )}\). □

### 3.4 The Approximation Algorithm

**decider**, with approximation parameter

*ε*>0. If any of these calls discover the approximate distance, then the algorithm immediately stops and returns the approximation. Therefore, at any point in the execution of the algorithm, the assumption is that all previous calls to

**decider**returned a direction where the optimal distance must lie. In particular, a call to

**searchInterval**\(( { \pi,\sigma,\mathcal{I}, {\varepsilon}} )\), would either find the approximate distance in the interval \(\mathcal{I}\) and return immediately, or the desired value is outside this interval.

#### 3.4.1 Correctness

### Lemma 3.12

*Given two polygonal curves* *π* *and* *σ*, *and a parameter* 1>*ε*>0, *the algorithm* **aprxFréchetI**(*π*,*σ*,*ε*) *computes a* (1+*ε*)-*approximation to* Open image in new window .

### Proof

If the algorithm found the approximation before step (F), then clearly it is the desired approximation, and we are done. (In particular, this must be the case if 4*α*′>*β*′/4.)

*μ*=3

*α*=(

*ε*/10)

*α*′≤

*β*′/4, it follows, by the triangle inequality, that A similar argument shows that Open image in new window . Hence, the algorithm of Lemma 3.11 can be applied to

*π*′ and

*σ*′ for the range [

*α*′,

*β*′], as Open image in new window .

*δ*resulting from step (G), is contained in the interval Open image in new window . By the triangle inequality we conclude that the returned Fréchet distance is since Open image in new window .

Note that Open image in new window since it is the width of a specific reparameterization between the two curves. □

#### 3.4.2 Running Time

### Lemma 3.13

*For any* *x*,*y*∈(2*α*,*β*/2), *we have* simpl(*π*,*x*)=simpl(*π*,*y*) *and* simpl(*σ*,*x*)=simpl(*σ*,*y*).

### Proof

Indeed, the interval (*α*,*β*) does not contain any value of *Z*. As such, by Lemma 3.9, (2*α*,*β*/2) does not contain any value of the pairwise distances between vertices of the vertex set of *π* and *σ* which implies that the simplification is the same for any value inside this interval. □

### Lemma 3.14

*Given two polygonal curves* *π* *and* *σ* *with a total of* *n* *vertices in *ℝ^{ d }, *and a parameter* 1>*ε*>0, *the running time of* **aprxFréchetI**(*π*,*σ*,*ε*) *is* *O*(N(*ε*,*π*,*σ*)log*n*).

### Proof

Computing *Z* (and sorting it) takes *O*(*n*log*n*) time by Lemma 3.9. Steps (C), (D) and (E) perform *O*(log*n*+log(1/*ε*))=*O*(log*n*) calls to **decider**, by Lemma 3.7. (Here, we assume that *ε*=*Ω*(1/*n*). If *ε*<1/*n* then we can just use the algorithm of Alt and Godau [3] since its running time is faster than our approximation algorithm in this case.) Each call to **decider** takes *O*(N(*ε*,*π*,*σ*)) time, so overall this takes *O*(N(*ε*,*π*,*σ*)log*n*) time. Computing the simplifications in step (F) with Algorithm 2.1 takes *O*(*n*) time.

**aprxFréchetNoSimp**(

*π*′,

*σ*′,[

*α*′,

*β*′],

*ε*/4) takes

*T*=

*O*((

*n*+

*N*)log(

*N*/

*ε*)) time, with

*N*=

*N*

_{≤β′}(

*π*′,

*σ*′). Now, 3

*α*and

*β*′ are both inside the interval (2

*α*,

*β*/2), and as such, by Lemma 3.13, we have

*π*′=simpl(

*π*,3

*α*)=simpl(

*π*,

*β*′) and

*σ*′=simpl(

*σ*,3

*α*)=simpl(

*σ*,

*β*′). Therefore, we have Thus, step (G) takes

*T*=

*O*(N(1,

*π*,

*σ*)log(N(1,

*π*,

*σ*)

*n*/

*ε*))=

*O*(N(1,

*π*,

*σ*)log

*n*), time since N(1,

*π*,

*σ*)≤

*n*

^{2}and

*ε*=

*Ω*(1/

*n*). Observe that N(1,

*π*,

*σ*)≤N(

*ε*,

*π*,

*σ*) for

*ε*≤1.

Finally, in order to compute the resulting reparameterizations in step (H), we compute the reparameterizations of *π* and *π*′ (resp. *σ* and *σ*′) as described in the proof of Lemma 2.3 and chain them with the reparameterizations of the simplified curves, which we obtained from step (G). Clearly, this and computing the resulting width takes *O*(*n*) time. Note that by the assumption in Remark 3.4 the term N(*ε*,*π*,*σ*) dominates over *O*(*n*). □

The running time of Lemma 3.14 can be slightly improved.

### Lemma 3.15

*The algorithm* **aprxFréchetI** *depicted in Fig*. 3 *can be modified to run in time* *O*(N(*ε*,*π*,*σ*)+N(1,*π*,*σ*)log*n*) (*see Definition *3.3).

### Proof

Use Lemma 3.14, with *ε* _{0}=1/2, to get a 2-approximation ζ for the Fréchet distance between *π* and *σ*. This takes *O*(N(1,*π*,*σ*)log*n*) time. Let \(\mathcal{I}_{0} = [\zeta,2\zeta]\) be the corresponding interval that contains the distance. We could call **searchInterval** \(({\pi,\sigma, \mathcal{I}_{0}, {\varepsilon}} )\) and get a (1+*ε*)-approximation in \(O ( \mathsf{N}({{\varepsilon}, \pi, \sigma} )\log\frac{1}{{\varepsilon}} +\allowbreak \mathsf{N}({1, \pi, \sigma } )\log n )\) time.

One can do better by starting with a “large” *ε* and decreasing it during the binary search for the right value performed by **searchInterval**. This is a standard idea and it was also used by Aronov and Har-Peled [5].

Indeed, assume that in the beginning of the *i*th step, we know that the required Fréchet distance lies in an interval \(\mathcal{I}_{i-1} = [\alpha_{i-1},\beta_{i-1}]\) and \(\beta_{i-1} -\alpha_{i-1}= \Vert{\mathcal{I}_{0}} \Vert {\varepsilon}_{i-1}\), where *ε* _{ i−1}=1/2^{ i−1}.

Let \(\varDelta_{i-1} = \Vert{\mathcal{I}_{i-1}} \Vert = \beta_{i-1}-\alpha_{i-1}\), and let *x* _{ i,j }=*α* _{ i−1}+*jΔ* _{ i−1}/4, for *j*=0,1,2,3,4. Call the procedure **decider** on three values *x* _{ i,1}, *x* _{ i,2}, and *x* _{ i,3}, with the approximation parameter being *c* _{1} *ε* _{ i }, for *c* _{1}>0 being a sufficiently small constant. Based on the outcome of these three calls, we can determine in constant time which of the three intervals \(\mathcal{J}_{i,1} = [x_{i,0}, x_{i,2}]\), \(\mathcal{J}_{i,2} = [x_{i,1}, x_{i,3}]\), or \(\mathcal{J}_{i,3} =[x_{i,2}, x_{i,4}]\) must contain the Fréchet distance. We set this interval to be \(\mathcal{I}_{i}\).

*M*steps, where

*M*=⌈lg1/

*ε*⌉. It is easy to verify that the final interval now provides the required approximation. The running time of this algorithm is \(O{ ( \mathsf{N}({1, \pi, \sigma} ) \log n + \sum_{i=1}^{M} \mathsf{N}({{\varepsilon}_{i}, \pi, \sigma}) )} \). Now, by assumption (P2) (see Definition 3.3), we have and this implies the claim. □

### The Result

Putting the above together, we get the following result.

### Theorem 3.16

*Given two polygonal curves* *π* *and* *σ* *with a total of* *n* *vertices in *ℝ^{ d }, *and a parameter* 1>*ε*>0, *one can* (1+*ε*)-*approximate the Fréchet distance between* *π* *and* *σ* *in* *O*(N(*ε*,*π*,*σ*)+N(1,*π*,*σ*)log*n*) *time* (*see Definition *3.3).

## 4 The Relative Free Space Complexity of Families of Curves

In this section we are going to bound the relative free space complexity for different realistic input models of curves. We will introduce the new class of *c*-*packed* curves, and we compare this new input model to the previous models of *κ-boundedness* and *low density*.

### 4.1 On *c*-Packed Curves

We introduce a new family of curves, *c*-packed curves, and prove that their relative free space complexity N(*ε*,*π*,*σ*) is linear, for any two curves *π* and *σ* in this family. This implies that Theorem 3.16 works in near linear time for *c*-packed curves, which is one of our main results.

#### 4.1.1 Definition and Basic Properties

### Definition 4.1

A curve *π* in ℝ^{ d } is *c-packed* if for any point *p* in ℝ^{ d } and any radius *r*>0, the total length of *π* inside the ball *B*(*p*,*r*) is at most *cr*.

### Lemma 4.2

*Let* *π* *be a curve in* ℝ^{ d }, *μ*>0 *be a parameter*, *and let* *π*′=simpl(*π*,*μ*) *be the simplified curve*. *Then* ∥*π*∩*B*(*p*,r+*μ*)∥≥∥*π*′∩*B*(*p*,r)∥ *for any ball* *B*(*p*,r).

### Proof

*π*′ that intersects

*B*(

*p*,r) and let v=u∩

*B*(

*p*,r) be this intersection. Let

*π*

_{ u }be the portion of

*π*that got simplified into u. Observe that

*π*

_{ u }is a polygonal curve that lies inside a hippodrome of radius

*μ*around u; that is, \(\pi_{\mathsf{u}}\subseteq\mathcal{H}_{\mathsf{u}}= \mathsf{u}\oplus B ( {0, \mu} )\), where ⊕ denotes the Minkowski sum of the two sets, see the figure below.

In particular, erect two hyperplanes passing through the endpoints of v that are orthogonal to v, and observe that *π* _{ u } must intersect both hyperplanes. Hence, we conclude that the portions of *π* _{ u } in the hippodrome \(\mathcal{H}_{\mathsf{v}}= \mathsf{v}\oplus B ( {0,\mu} )\) are of length at least ∥v∥. Clearly, v⊆*B*(*p*,r) implies that \(\mathcal{H}_{\mathsf{v}}\subseteq B ( {p, \mathsf{r}+ \mu} )\), which in turn implies that \(\pi_{\mathsf{u}}\cap\mathcal{H}_{\mathsf{v}}\subseteq B ( {p,\mathsf{r}+ \mu} )\) and thus ∥*π* _{ u }∩*B*(*p*,r+*μ*)∥≥∥v∥.

Summing over all segments v in *π*′∩*B*(*p*,r) implies the claim. □

### Lemma 4.3

*Let* *π* *be a* *c*-*packed curve in* ℝ^{ d }, *μ*>0 *be a parameter*, *and let* *π*′=simpl(*π*,*μ*) *be the simplified curve*. *Then*, *π*′ *is a* 6*c*-*packed curve*.

### Proof

Assume, for the sake of contradiction, that ∥*π*′∩*B*(*p*,r)∥>6*c* r for some *B*(*p*,r) in ℝ^{ d }. If r≥*μ*, then set r′=2r and Lemma 4.2 implies that ∥*π*∩*B*(*p*,r′)∥≥∥*π*∩*B*(*p*,r+*μ*)∥≥∥*π*′∩*B*(*p*,r)∥>6*c* r=3*c* r′, which contradicts that *π* is *c*-packed.

If r<*μ* then let *U* denote the segments of *π*′ intersecting *B*(*p*,r) and let *k*=|*U*|. Observe that *k*>6*c* r/2r=3*c*, as any segment can contribute at most 2r to the length of *π*′ inside *B*(*p*,r). Therefore we have ∥*π*′∩*B*(*p*,2*μ*)∥≥∥*π*′∩*B*(*p*,r+*μ*)∥≥∥*U*∩*B*(*p*,r+*μ*)∥≥*kμ*, since every segment of the simplified curve *π*′ has a minimal length of *μ*. By Lemma 4.2, this implies that ∥*π*∩*B*(*p*,3*μ*)∥≥∥*π*′∩*B*(*p*,2*μ*)∥≥*kμ*>3*cμ*, which is a contradiction to the *c*-packedness of *π*. □

#### 4.1.2 Bounding the Relative Free Space Complexity

### Lemma 4.4

*For any two* *c*-*packed curves* *π* *and* *σ* *in* ℝ^{ d }, *and* 0<*ε*<1, *we have* N(*ε*,*π*,*σ*)=*O*(*cn*/*ε*).

### Proof

Let *δ*≥0 be an arbitrary number, *μ*=*εδ*, *π*′=simpl(*π*,*μ*) and *σ*′=simpl(*σ*,*μ*)

*D*

_{≤δ }(

*π*′,

*σ*′) is

*O*(

*cn*/

*ε*). A free space cell of

*D*

_{≤δ }(

*π*′,

*σ*′) corresponds to two segments u∈

*π*′ and v∈

*σ*′. The free space in this cell is non-empty if and only if there are two points

*p*∈u and

*q*∈v such that ∥

*p*−

*q*∥≤

*δ*. We charge this pair of points to the shorter of the two segments. We claim that a segment cannot be charged too many times.

*π*′, and consider the ball

*B*of radius

*r*=(3/2)∥u∥+

*δ*centered at the midpoint of u, see the figure above. Every segment v∈

*σ*′ that participates in a close pair as above and charges u for it, is of length at least ∥u∥, and the length of v∩

*B*is at least ∥u∥. Since

*σ*′ is 6

*c*-packed, by Lemma 4.3, we see that the number of such charges is at most since ∥u∥≥

*μ*.

We conclude that there are at most *c*′*n* free space cells that contain a point of *D* _{≤δ }. The complexity of the free space inside a cell is a constant, thus implying the claim. □

By plugging the above into Theorem 3.16, we get the following result.

### Theorem 4.5

*Given two polygonal* *c*-*packed curves* *π* *and* *σ* *with a total of* *n* *vertices in* ℝ^{ d }, *and a parameter* 1>*ε*>0, *one can* (1+*ε*)-*approximate the Fréchet distance between* *π* *and* *σ* *in* *O*(*cn*/*ε*+*cn*log*n*) *time*.

### 4.2 Relative Free Space Complexity of Low-Density Curves

### Definition 4.6

A polygonal curve *π* in ℝ^{ d } is *ϕ-low density* if any ball *B*(*p*,*r*) intersects at most *ϕ* segments of *π* that are longer than *r*.

First, observe that this input model is less restrictive than the input model which describes c-packed curves. It can be easily seen by a simple packing argument that a polygonal *c*-packed curve is *ϕ*-low density, for *ϕ*=2*c*. For any ball *B*=*B*(*p*,*r*), consider the ball with the same center that has radius *r*′=2*r*. Any edge intersecting *B* that is longer than *r* must contribute at least *r* to the length of the intersection of the curve with the larger ball, which is bounded by *cr*′. There can be at most *cr*′/*r*=2*c* edges of this type.

*c*-packed for a small value of

*c*. Indeed, a low-density curve

*π*might have an arbitrarily long intersection with a ball by having sufficiently small segments, see the figure below. However, in this case

*π*must have many vertices in the areas where its length cannot be bounded, as we will show in the following section.

### Claim 4.7

*Let* *π* *be a* *ϕ*-*low density polygonal curve*, *and let* *C* *be a hypercube in* ℝ^{ d } *with side length* *ℓ*. *Then*, *the number of edges of length* ≥*ℓ* *of* *π* *that intersect* *C* *is bounded by* *c* _{ d } *ϕ*, *where* \(c_{d}=\lceil{\sqrt{d} / 2 } \rceil^{d}\).

### Proof

*C*into a

*D*×

*D*×⋯×

*D*grid, for \(D = \lceil{\sqrt{d} / 2 } \rceil\). Clearly, any edge that intersects

*C*that has length ≥

*ℓ*must intersect one of the hypercubes in this grid. A hypercube of this grid has diameter and is included in a ball of radius

*ℓ*. Thus, a hypercube in this grid intersects at most

*ϕ*such long edges. We conclude that there can be at most

*ϕD*

^{ d }long edges intersecting

*C*. □

#### 4.2.1 Low-Density Curves Can Be Long Only if They Pay for It

Lemma 4.8 below testifies that the parts of a low-density curve, where its length cannot be bounded by a constant, can be covered with hypercubes, such that each cube intersects at most a constant number of edges and at most a constant number of other cubes. We use this construction in Lemma 4.9 to relate the length of a low-density curve to the diameter of the covered area to the number of vertices. One can verify Lemma 4.8 using an easy modification of a lemma from [13]. We provide a proof, for the sake of completeness, in Appendix B.

### Lemma 4.8

*Let* *π* *be a* *ϕ*-*low density curve*, *of which* *n* *edges are intersecting a given hypercube* *C* *of* ℝ^{ d }. *The hypercube* *C* *can be covered by a set of hypercubes* Open image in new window , *such that* (i) Open image in new window , (ii) Open image in new window , (iii)* any point* *p*∈*C* *is covered by at most* 2^{ d } *hypercubes*, *and* (iv)* each hypercube of* Open image in new window *intersects at most* *c* _{ d } *ϕ* *edges of* *π*, *where* *c* _{ d } *is a constant that depends only on the dimension* *d*.

### Lemma 4.9

*Let* *π* *be a* *ϕ*-*low density curve in* ℝ^{ d }, *and let* *C* *be a cube in* ℝ^{ d } *with side length* *r*. *Let* *α*=∥*π*∩*C*∥. *There must be at least* *Ω*((*α*/*r*)^{1+1/(d−1)}) *vertices of* *π* *contained in* 3*C*, *where* 3*C* *is the scaling of* *C* *by a factor of* 3 *around its center*.

### Proof

We will first give a lower bound on the number *n* of edges intersecting *C* (i.e., the edges that contribute to *α*). Then we will account for the edges that have endpoints outside 3*C*. So, take the *n* edges of *π* that intersect *C* and construct the cover of *C* resulting from Lemma 4.8 with respect to these edges.

Let *C* _{1},…,*C* _{ N } denote the cubes in this cover, where *r* _{1}≤*r* _{2}≤…≤*r* _{ N } are the side lengths of the cubes used by the cover, respectively. Lemma 4.8 implies that *N*≤2^{ d+1} *dn*, and, therefore, a lower bound on *N* would provide a lower bound on *n*.

*N*cubes bounds the length of the intersection \(\alpha\leq\sum_{i=1}^{N} c_{d}\phi\sqrt{d}r_{i}\), since every cube in this cover can intersect at most

*c*

_{ d }

*ϕ*edges of

*π*. Setting

*p*=

*d*and

*q*=

*d*/(

*d*−1), we observe that 1/

*p*+1/

*q*=1/

*d*+(

*d*−1)/

*d*=1, and by Hölder’s inequality,

^{1}we have

^{ d }vol(

*C*), since every point in

*C*is covered at most 2

^{ d }times by this cover. Therefore we have \(\sum_{i=1}^{N} r_{i}^{d} = \sum_{i=1}^{N}\mathrm{vol} ( {C_{i}} ) \leq2^{d} \mathrm{vol} ({C} ) = 2^{d} r^{d}\). Hence This implies that

*c*

_{2}(

*α*/

*r*)

^{ d/(d−1)}≤

*N*, where \(c_{2}= { ( { 2 c_{d}\phi\sqrt{d}})}^{-d/(d-1)}\). Since

*N*≤2

^{2d+1}

*n*, we have

*c*

_{3}(

*α*/

*r*)

^{ d/(d−1)}≤

*n*, where \(c_{3}=\frac{1}{2^{2d+1} }{ ( { 2 c_{d}\phi\sqrt{d}} )}^{-d/(d-1)}\).

Now, some of these *n* edges intersecting *C* can have both endpoints outside 3*C*. Such edges are longer than the side length of *C* and by Claim 4.7 their number is bounded by *c* _{ d } *ϕ*.

Hence, the number of vertices of *π* inside 3*C* is at least *n* − *c* _{ d } *ϕ* ≥ *c* _{3}(*α*/*r*)^{ d/(d−1)}−*c* _{ d } *ϕ*. □

### Remark 4.10

One can also prove Lemma 4.9 directly, by building a quadtree and arguing that for a low-density curve to be sufficiently long, many edges in it have to be (sufficiently) short, thus implying the same bound. However, the current proof is more intuitive and cleaner.

### Observation 4.11

The bound in Lemma 4.9 is tight. For any *m*>0 and any *d*>0, consider the integer grid in ℝ^{ d } with coordinates in the range 1,…,*m*, and compute a path that visits all these grid points using only the grid edges of unit length, which is clearly possible.

Now, the resulting curve is 2^{ d }-low density and has length *α*=*m* ^{ d }−1 and its diameter is \(r=\sqrt{d}m\). Lemma 4.9 implies that it has *Ω*((*α*/*r*)^{ d/(d−1)})=*Ω*(*m* ^{ d }) vertices. Since this grid has *m* ^{ d } vertices, this is tight.

#### 4.2.2 Accounting for Many Reachable Free Space Cells

If many columns of the free space diagram of the two simplified low-density curves contain a linear number of reachable cells, then the curve must be “long” in the vicinity of the edges corresponding to those columns, since the simplification ensures a minimal edge length. A similar argument holds for the rows. Therefore, using Lemma 4.9, we can charge the additional reachable cells to vertices of the original curves. This yields the following result.

### Lemma 4.12

*For any two low*-*density curves* *π* *and* *σ* *in* ℝ^{ d }, *and* 0<*ε*<1, *we have* \(\mathsf{N}({{\varepsilon}, \pi, \sigma} ) = O {( \frac {n^{2(d-1)/d}}{{\varepsilon}^{2}} )}\).

### Proof

Let *δ*≥0 be an arbitrary radius, and let *π*′=simpl(*π*,*μ*) and *σ*′=simpl(*σ*,*μ*) be their simplifications, where *μ*=*εδ*. Then, we need to prove that \(N_{\leq\delta}(\pi', \sigma') = O { ( \frac {n^{2(d-1)/d}}{{\varepsilon}^{2}} )}\).

To this end, it suffices to bound the number of vertex–edge pairs (*p*,u), where *p* is a vertex of *π*′, u is an edge of *σ*′, and the distance between *p* and u is at most *δ* (naturally, we need to apply the same argument to pairs with vertices in *σ*′ and edges in *π*′). The total number of such pairs bounds the total complexity of Open image in new window .

Set *M*=*O*(*n* ^{1−2/d }/*ε* ^{2}), and associate every vertex–edge pair (*p*,u) that appears in the free space diagram Open image in new window with the vertex *p*.

*δ*. For a grid cell R, consider the vertex of

*π*′ in R that is associated with the largest number of such vertex–edge pairs, and say it is being associated with d

_{ R }such vertex–edge pairs, and let

*v*

_{ R }denote this “popular” vertex of

*π*′. The total number of vertex–edge pairs associated with vertices of

*π*′ inside R is bounded by

*U*

_{ R }=|

*π*′⊓R| d

_{ R }, where |

*π*′⊓R| denotes the number of vertices of

*π*′ that lie inside R.

If d _{ R }≤*M* then *U* _{ R }≤|*π*′⊓R|*M*, and we charge *M* units to each vertex of *π* inside R.

If d _{ R }>*M* then the length of *σ*′ inside *C*/3 is at least d _{ R } *μ*, where *C* is a cube centered at R with side length *O*(*δ*). Indeed, all the charges d _{ R } rise from different segments of *σ*′ that are in distance at most *δ* from *v* _{ R }, and each such segment has length at least *μ*.

*σ*must have at least

*Ω*((d

_{ R }

*μ*/

*δ*)

^{ d/(d−1)})=

*Ω*((d

_{ R }

*ε*)

^{ d/(d−1)}) vertices inside

*C*. There is some constant

*c*such that by picking

*M*to be sufficiently large. In particular, if |

*π*′⊓R|≤d

_{ R }, then \(U_{\mathsf{R}}=\lvert{\pi'} \sqcap\nobreak \mathsf{R} \rvert\, \mathsf{d}_{\mathsf{R}}\leq\mathsf{d}_{\mathsf{R}}^{2} \leq M\lvert{\sigma} \sqcap{C}\rvert\). Hence, we charge

*M*units to each vertex of

*σ*inside the cube

*C*.

Otherwise, |*π*′⊓R|>d _{ R }>*M*. But then, the length of *π*′ inside *C* is at least |*π*′⊓R|*μ*, and by Lemma 4.9, we see that *π* must have at least *Ω*((|*π*′⊓R|*ε*)^{ d/(d−1)}) vertices inside *C*. Arguing as above, this implies that |*π*′⊓R|^{2}≤*M*|*π*⊓*C*|. As such, we have *U* _{ R }=|*π*′⊓R| d _{ R }≤|*π*′⊓R|^{2}≤*M*|*π*⊓*C*|. Again, we charge *M* units to each vertex of *π* inside the cube *C*.

Since *C* intersects a constant number of cells of the grid, no vertex would get charged more than a constant number of times by the above scheme. Thus, every vertex, of either curve, gets charged *O*(*M*) units overall, and the total number of vertex–edge pairs present in Open image in new window is *O*(*nM*), as claimed. □

### Observation 4.13

One can extend the construction of Observation 4.11 to show that Lemma 4.12 is close to being tight. Indeed, consider the grid curve of Observation 4.11 in *d*−1 dimensions, for an integer *m*. We now lift it to *d* dimensions by considering the [1,*m*]^{ d } cube and placing two copies of the above curve on two opposite faces of the cube, denoted by *f* and *f*′. Let *π* _{1} and *π* _{2} denote these two copies.

Next, delete the even edges from *π* _{1} and the odd edges from *π* _{2}. Connect every vertex *v* _{1} of *π* _{1} to its corresponding (copied) vertex *v* _{2} in *π* _{2} by a path made out of the *m*−1 unit edges along the grid line connecting the two vertices. This results in a curve *π* that is similar to the curve constructed in Observation 4.11, but has the advantage that when simplified for the distance *μ*=*m* it results in a curve with *m* ^{ d−1} segments of length ≥*m* that connects points that lie on *f* and on *f*′, respectively.

Let *σ* be a copy of *π*. For a fixed *ε*>0, we can add a single segment to *π* such that the Fréchet distance between the resulting curves is exactly *δ*=*m*/*ε*. Now, these two curves have *n*=2*m* ^{ d }+2 vertices overall, and furthermore, when we simplify them for the distance *μ*=*εδ*=*m*, we end up with two curves such that every long edge of *π*′ is going to be in distance ≤*δ*=*m*/*ε* from a constant fraction of the edges of *σ*′ (this would be all the edges if \(1/{\varepsilon}> \sqrt{d}\)). Therefore the complexity of the reachable free space is *Ω*(n _{ π′} n _{ σ′})=*Ω*((*m* ^{ d−1})^{2})=*Ω*(*n* ^{2(d−1)/d }), where n _{ π′} denotes the number of vertices of *π*′. The upper bound of Lemma 4.12 is (only) larger by a factor of *O*(1/*ε* ^{2}).

By plugging the above into Theorem 3.16, we get the following result.

### Theorem 4.14

*Given two low*-*density curves* *π* *and* *σ* *with a total of* *n* *vertices in *ℝ^{ d }, *and a parameter* *ε*>0, *there exists an algorithm which* (1+*ε*)-*approximates the Fréchet distance between* *π* *and* *σ* *in* \(O { (\frac{n^{2(d-1)/d}}{{\varepsilon}^{2}} + n^{2(d-1)/d} \log n )}\) *time*.

### 4.3 Relative Free Space Complexity of *κ*-Bounded Curves

We revisit the definitions of Alt et al. [4] of *κ*-bounded and *κ*-straight curves. Note that these definitions describe an extremely restricted class of curves while *c*-packed curves form a fairly general and natural class of curves. However, it is not true that any *κ*-bounded curve is *O*(*κ*)-packed. We therefore give a separate proof to bound the relative free space complexity of *κ*-bounded curves in order to improve upon the result in [4].

### Definition 4.15

Let *κ*≥1 be a given parameter. A curve *π* is *κ-straight* if for any two points *p* and *q* on the curve, we have ∥*π*[*p*,*q*]∥≤*κ*∥*p*−*q*∥.

*π*is a

*κ-bounded*if for all

*p*,

*q*∈

*π*we find that the curve

*π*[

*p*,

*q*] is contained inside

*B*(

*p*,

*r*)∪

*B*(

*q*,

*r*), where

*r*=(

*κ*/2)∥

*p*−

*q*∥, see the figure below.

### Lemma 4.16

*A* *κ*-*straight curve is* 2*κ*-*packed*.

### Proof

Let *π* be a *κ*-straight curve in ℝ^{ d }, and consider any ball *B*(*p*,*r*) that intersects it. Let *q* and *s* be the first and last points, respectively, along *π* that are in *B*(*p*,*r*). Clearly, ∥*q*−*s*∥≤2*r*, and by the *κ*-straightness ∥*π*∩*B*(*p*,*r*)∥≤∥*π*[*q*,*s*]∥≤*κ*∥*q*−*s*∥≤2*κr*. □

### Remark 4.17

*κ*-straight curve is also

*κ*-bounded. However,

*κ*-bounded curves, counterintuitively, can have infinite length even when contained inside a finite domain. An example of this is

*Koch’s snowflake*, which is a fractal curve depicted in Fig. 4.

To see, intuitively, why Koch’s snowflake is *κ*-bounded, let *π* _{ i } be the *i*th polygonal curve generated by this process. There is a natural mapping between any point of *π* _{ i } and *π* _{ i+1}, for all *i*. In particular, consider two points *p* and *q* on the final curve *π* ^{∗}, and consider the two sequences of points *p* _{ i },*q* _{ i }∈*π* _{ i }, where *p* _{ i+1}∈*π* _{ i+1} (resp. *q* _{ i+1}∈*π* _{ i+1}) is the natural image of *p* _{ i } (resp. *q* _{ i }), lim_{ i→∞} *p* _{ i }=*p*, and lim_{ i→∞} *q* _{ i }=*q*.

Now, assume that *r*=∥*p*−*q*∥. Observe that, for all *i*, the polygonal curve *π* _{ i } is made out of segments that are all of the same length. In particular, consider the first index *k*, such that this segment length of *π* _{ k } is of length ≤*r*/20. It is easy to argue that ∥*p* _{ k }−*p*∥≤*r*/5 and ∥*q* _{ k }−*q*∥≤*r*/5. In fact, one can argue that no point of *π* _{ k } moves more than a distance larger than *r*/5 to its final location on *π* ^{∗}.

Now, a tedious argument shows that there are *O*(1) segments of *π* _{ k } separating *p* _{ k } from *q* _{ k }. Therefore this portion of the curve *π* _{ k } is covered by a disk of radius *O*(*r*), and the corresponding portion of the final curve between *p* and *q* is also covered by a disk of radius *O*(*r*). This implies that Koch’s snowflake is *κ*-bounded.

A formal proof of this fact is considerably more tedious and is omitted.

### Lemma 4.18

*Let* *π* *be a* *κ*-*bounded polygonal curve in* ℝ^{ d }, *and let* *μ*≤*δ* *be parameters*. *Let* *π*′=simpl(*π*,*μ*). *Then the number of segments of* *π*′ *intersecting* *B*(*s*,*δ*) *is bounded by* *O*(*κ* ^{ d }(1+*δ*/*μ*)^{ d }), *for any* *s*∈ℝ^{ d }.

### Proof

For *π*=u _{1} u _{2}…u _{ k }, let *Y* _{ O }={u _{1},u _{3},…} and *Y* _{ E }={u _{2},u _{4},…} be the sets of odd and even segments of *π*′, respectively.

Let *X* _{ O }⊆*Y* _{ O } be the set of odd segments of *π*′ intersecting *B*(*s*,*δ*). For all *i*, pick an arbitrary point *p* _{ i } on the *i*th segment of *X* _{ O } that lies inside *B*(*p*,*δ*). Next, pick an original point *q* _{ i } of *π* in distance at most *μ* from *p* _{ i }, for *i*=1,…,*M*=|*X* _{ O }|. Observe that for all *i* we have ∥*s*−*q* _{ i }∥≤*δ*+*μ*. Furthermore, between any two distinct points *p* _{ i } and *p* _{ j } on the simplified curve *π*′ there must lie an even segment of *Y* _{ E } in between them along the curve, and the length of this segment is at least *μ* (because the simplification algorithm generates segments of length at least *μ*). Also, the endpoints of this even segment lie on the original curve *π*.

*q*

_{1},…,

*q*

_{ M }} can be too close to each other; that is, there are no two points

*q*′,

*q*″∈Q, such that

*r*=∥

*q*′−

*q*″∥≤

*μ*/(4

*κ*). Indeed, assume for the sake of contradiction, that there are two such points. Then, by the above, the portion of

*π*connecting them contains two points

*t*′,

*t*″ that are at least

*μ*apart. Observe that

*π*[

*t*′,

*t*″]⊆

*X*=

*B*(

*q*′,(

*κ*/2)

*r*)∪

*B*(

*q*″,(

*κ*/2)

*r*). However, the maximum distance between two points that are included inside

*X*is bounded by its diameter. We have since

*κ*>1. A contradiction.

However, all the points of Q lie inside a ball of radius *δ*+*μ* centered at *s*. Now, placing a ball of radius *μ*′=*μ*/(8*κ*) around each point of Q, results in a set of interior disjoint balls. This implies, by a standard packing argument, that the number of points of Q is bounded by vol(*B*(*s*,*δ*+*μ*))/vol(*B*(⋅,*μ*′))=*O*((*δ*+*μ*)^{ d }/(*μ*/*κ*)^{ d })=((1+*δ*/*μ*)^{ d } *κ* ^{ d }).

This bounds the number of odd segments of *π*′ intersecting the ball *B*(*s*,*δ*), and a similar argument holds for the even segments intersecting this ball. □

### Lemma 4.19

*For any two* *κ*-*bounded polygonal curves in* ℝ^{ d } *π* *and* *σ*, 0<*ε*<1, *we have* N(*ε*,*π*,*σ*)=*O*((*κ*/*ε*)^{ d } *n*).

### Proof

Let *δ*≥0 be an arbitrary radius, and set *μ*=*εδ*. Let *π*′=simpl(*π*,*μ*) and *σ*′=simpl(*σ*,*μ*). We need to show that the complexity of the reachable free space Open image in new window is *O*(*κ* ^{ d }(1+*δ*/*μ*)^{ d } *n*)=*O*((*κ*/*ε*)^{ d } *n*).

The boundary of a reachable cell in the free space diagram has a non-empty intersection with *D* _{≤δ }(*π*′,*σ*′). Otherwise its interior could not be reached by a monotone path from (0,0). Therefore, using an argument similar to the proof of Lemma 4.4, Lemma 4.18 implies the desired bound. □

By plugging the above into Theorem 3.16, we get the following result.

### Theorem 4.20

*Given two* *κ*-*bounded polygonal curves* *π* *and* *σ* *with a total of* *n* *vertices in* ℝ^{ d }, *and a parameter* 1>*ε*>0, *there exists an algorithm which* (1+*ε*)-*approximates the Fréchet distance between* *π* *and* *σ* *in* *O*((*κ*/*ε*)^{ d } *n*+*κ* ^{ d } *n*log*n*) *time*.

## 5 Extension to Closed *c*-Packed Curves

The Fréchet distance for closed curves is defined as in Sect. 2 with the altered condition that the reparameterizations *f* and *g* are orientation-preserving homeomorphisms on the one-dimensional sphere. Computing the Fréchet distance for closed curves is more difficult, as the constraint that the endpoints of the curves have to be matched to each other is dropped in this case and therefore the set of reparameterizations one has to consider is larger.

### Observation 5.1

The decision problem for closed curves can be reduced to the previously considered case of open curves. Given two closed *c*-packed curves *π* and *σ* and a parameter *δ*. Pick a vertex *p* of the curve *π*, and assume that we know a point *q* on *σ* that is being matched to *p* by a pair of reparameterizations of *π* and *σ* of width at most *δ*. Clearly, if we break *π* open at *p*, and *σ* at *q*, we retrieve two open curves \(\widehat{\pi}\) and \(\widehat{\sigma}\), and we can use the previous method to decide if Open image in new window . Hence we only need to generate a suitable set of candidates for *q* to determine if the Fréchet distance between *π* and *σ* is at most *δ* within a certain approximation error.

### Lemma 5.2

*Let* *π* *be a closed* *c*-*packed polygonal curve in* ℝ^{ d }, *and let* *μ*≤*δ* *be parameters*. *Let* *π*′=simpl(*π*,*μ*). *Then the number of edges of* *π*′ *intersecting* *B*(*p*,*δ*) *is bounded by* *O*(*cδ*/*μ*), *for any* *p*∈ℝ^{ d }.

### Proof

Consider the ball *B*=*B*(*p*,*r*) of radius *r*=*μ*+*δ*. Any edge u of *π*′ that intersects *B*(*p*,*δ*) has to contribute at least *μ* to the length of the intersection with *B*, as the simplification guarantees that every edge of *π*′ is of length at least *μ*. Since *π*′ is 6*c*-packed, by Lemma 4.3, we have ∥*B*∩*π*′∥≤6*cr*, and the number of intersections of *π*′ with *B*(*p*,*δ*) is *N*≤∥*B*∩*π*′∥/*μ*≤6*cr*/*μ*=6*c*(*μ*+*δ*)/*μ*=*O*(*c*+*cδ*/*μ*), which implies the claim. □

### Lemma 5.3

*Given two closed* *c*-*packed polygonal curves* *π* *and* *σ* *with a total number of* *n* *vertices and parameters* *δ* *and* 1>*ε*>0. *Let* *π*′=simpl(*π*,*μ*) *and* *σ*′=simpl(*σ*,*μ*) *denote the curves simplified with* *μ*≤*εδ* *and let* *p* *be a vertex of π*′. *We can compute a set of points* Open image in new window *of size* *O*(*c*/*ε*), *in* *O*(*n*+*c*/*ε*) *time*, *such that if* Open image in new window *then there exists a pair of reparameterizations of width at most* (1+*ε*)*δ* *that matches* *p* *to an element of* Open image in new window .

### Proof

*σ*′ starting from an arbitrary point. If the starting point is in distance

*δ*from

*p*, then we add it to the candidate set Open image in new window . As we follow along the curve we create a candidate if we

- (a)
(re-)enter the ball

*B*(*p*,*δ*), or - (b)
have traveled a distance

*εδ*along*σ*′ since the last creation of a candidate, unless we have exited the ball*B*(*p*,*δ*) in the meantime.

The number of events of type (a) is bounded (up to a factor of 2) by the number of intersections of *σ*′ with the sphere *S*(*p*,*δ*), and by Lemma 5.2, this number is bounded by *O*(*cδ*/*μ*)=*O*(*c*/*ε*). By Lemma 4.3 the simplified curve *σ*′ is 6*c*-packed and therefore the length of its intersection with *B*(*p*,*δ*) is at most 6*cδ*. This implies that we can have at most *O*(6*cδ*/*μ*)=*O*(6*c*/*ε*) candidates that were created at events of type (b).

*π*′ and

*σ*′ of width at most

*δ*. Next, consider a point

*q*∈

*σ*′ that is matched to

*p*∈

*π*′ by these reparameterizations. Observe that

*q*∈

*B*(

*p*,

*δ*) and there exists, by construction, a point Open image in new window such that ∥

*q*−

*q*′∥≤

*εδ*. Let

*p*′ be a point on

*π*′ that is matched to

*q*′ by the given reparameterizations.

We match the curve segment \(\widehat{\sigma}\) between *q* and *q*′ to *p* and the curve segment \(\widehat{\pi}\) between *p* and *p*′ to *q*, see the figure above. Clearly this preserves the monotonicity of the matching. By the triangle inequality, any point on \(\widehat{\sigma}\) has distance at most (1+*ε*)*δ* to *p*. Similarly, for any point on \(\widehat{\pi}\) there is a point on \(\widehat{\sigma}\) that is in distance *δ*, therefore *q*′ is in distance (1+*ε*)*δ* of \(\widehat{\pi}\).

We conclude that the Fréchet distance between *π*′ and *σ*′ is at most (1+*ε*)*δ* when restricted to reparameterizations matching *p* to *q*′. □

One can adapt Lemma 3.5 to the closed curves case, by considering the *O*(*cn*/*ε*) open curves that result from breaking *σ*′ at any point of Open image in new window . The details of the adaption are straightforward, and we only state the result.

### Lemma 5.4

*Given two closed polygonal*

*c*-

*packed curves*

*π*

*and*

*σ*

*with a total of*

*n*

*vertices in*ℝ

^{ d },

*and parameters*

*δ*

*and*1>

*ε*>0.

*Then*,

*there exists an algorithm which*,

*in*

*O*((

*c*/

*ε*)

^{2}

*n*)

*time*,

*correctly outputs one of the following*:

- (A)
*If*Open image in new window*then the algorithm outputs “*≤(1+*ε*)*δ”*. - (B)
*If*Open image in new window*then the algorithm outputs “*Open image in new window*”*. - (C)
*If*Open image in new window*then the algorithm outputs either of the above outcomes*.

Plugging Lemma 5.4 into the algorithm of Theorem 3.16, we get the following result.

### Theorem 5.5

*Given two closed polygonal* *c*-*packed curves* *π* *and* *σ* *with a total of* *n* *vertices in* ℝ^{ d }, *and a parameter* 1>*ε*>0, *one can* (1+*ε*)-*approximate the Fréchet distance between* *π* *and* *σ* *in* *O*(*c* ^{2} *n*(*ε* ^{−2}+log*n*)) *time*.

## 6 Conclusions

We presented a new approximation algorithm for the Fréchet distance for polygonal curves in any fixed dimension. The new algorithm is surprisingly simple and should be practical. Furthermore it works for any kind of polygonal curves. Since the algorithm simplifies the curves to the “right” resolution during the execution, we expect the algorithm to be fast in practice. The algorithm’s analysis relies on the concept of the relative free space complexity of curves, which tries to capture the complexity of the free space diagram when simplification is being used.

Next, we introduced the *c*-packed family of curves. While not all curves are *c*-packed, it seems that most real life curves are *c*-packed. The family of *c*-packed curves is closed under simplification, and the property of a curve being *c*-packed is independent of the ambient dimension of the space containing the curve. We expect this concept to be used to analyze other algorithms in the future.

In particular, the relative free space complexity of *c*-packed curves is linear. We gave bounds for the relative free space complexity for several other types of curves, from low-density curves to *κ*-bounded curves. Finally, we also showed that the algorithm can be modified to handle closed curves efficiently.

### Lower Bound

Our solution to the decision problem “beats” the lower bound of *Ω*(*n*log*n*) [9], by a factor of log*n* (see Lemma 3.5). Since our decision procedure is approximated this is not too surprising. However, it is enlightening to consider where this proof breaks for our settings. Indeed, Buchin et al. [9] generate two curves such that the Fréchet distance might be realized by one vertex of one curve matching the whole other curve. On the other hand, in our case, the input model coupled with simplification guarantees that the number of segments matching a single vertex is only a constant.

## Footnotes

- 1.
Hölder’s inequality states that \(\sum_{i=1}^{n}\lvert a_{i} b_{i}\rvert \leq{ ( \sum_{i=1}^{n} \lvert a_{i}\rvert^{q})}^{1/q}{ ( \sum_{i=1}^{n} \lvert b_{i}\rvert^{p} )}^{1/p}\) if 1/

*p*+1/*q*=1.

## Notes

### Acknowledgements

The authors thank Mark de Berg and Marc van Kreveld for insightful discussions on the problems studied in this paper and related problems. The authors would also like to thank the anonymous referees for their insightful comments.

This research was initiated during a workshop supported by the Netherlands Organization for Scientific Research (NWO) under BRICKS/FOCUS grant number 642.065.503.

The work of A. Driemel has been supported by the Netherlands Organisation for Scientific Research (NWO) under RIMGA (Realistic Input Models for Geographic Applications). The work of S. Har-Peled was partially supported by a NSF AF award CCF-0915984. The work of C. Wenk has been supported by NSF CAREER award CCF-0643597.

### References

- 1.Agarwal, P.K., Har-Peled, S., Mustafa, N., Wang, Y.: Near-linear time approximation algorithms for curve simplification in two and three dimensions. Algorithmica
**42**, 203–219 (2005) MathSciNetMATHCrossRefGoogle Scholar - 2.Alt, H.: The computational geometry of comparing shapes. In: Efficient Algorithms: Essays Dedicated to Kurt Mehlhorn on the Occasion of His 60th Birthday, pp. 235–248. Springer, Berlin (2009) Google Scholar
- 3.Alt, H., Godau, M.: Computing the Fréchet distance between two polygonal curves. Int. J. Comput. Geom. Appl.
**5**, 75–91 (1995) MathSciNetMATHCrossRefGoogle Scholar - 4.Alt, H., Knauer, C., Wenk, C.: Comparison of distance measures for planar curves. Algorithmica
**38**(1), 45–58 (2004) MathSciNetMATHCrossRefGoogle Scholar - 5.Aronov, B., Har-Peled, S.: On approximating the depth and related problems. SIAM J. Comput.
**38**(3), 899–921 (2008) MathSciNetMATHCrossRefGoogle Scholar - 6.Aronov, B., Har-Peled, S., Knauer, C., Wang, Y., Wenk, C.: Fréchet distance for curves, revisited. In: Proc. 14th Annu. European Symp. Algorithms, pp. 52–63 (2006) Google Scholar
- 7.Bose, P., Cheong, O., Dujmović, V.: A note on the perimeter of fat objects. Comput. Geom. Theory Appl.
**44**(1), 1–8 (2011) MATHCrossRefGoogle Scholar - 8.Brakatsoulas, S., Pfoser, D., Salas, R., Wenk, C.: On map-matching vehicle tracking data. In: Proc. 31st VLDB Conference, pp. 853–864 (2005) Google Scholar
- 9.Buchin, K., Buchin, M., Knauer, C., Rote, G., Wenk, C.: How difficult is it to walk the dog. In: Proc. 23rd Euro. Workshop on Comput. Geom., pp. 170–173 (2007) Google Scholar
- 10.Buchin, K., Buchin, M., Gudmundsson, J.: Detecting single file movement. In: Proc. 16th ACM SIGSPATIAL Int. Conf. Adv. GIS, pp. 288–297 (2008) Google Scholar
- 11.Buchin, K., Buchin, M., Gudmundsson, J., Maarten, L., Luo, J.: Detecting commuting patterns by clustering subtrajectories. In: Proc. 19th Annu. Internat. Symp. Algorithms Comput., pp. 644–655 (2008) Google Scholar
- 12.Callahan, P.B., Kosaraju, S.R.: A decomposition of multidimensional point sets with applications to
*k*-nearest-neighbors and*n*-body potential fields. J. Assoc. Comput. Mach.**42**, 67–90 (1995) MathSciNetMATHCrossRefGoogle Scholar - 13.de Berg, M.: Linear size binary space partitions for uncluttered scenes. Algorithmica
**28**, 353–366 (2000) MathSciNetMATHCrossRefGoogle Scholar - 14.de Berg, M.: Improved bounds on the union complexity of fat objects. Discrete Comput. Geom.
**40**(1), 127–140 (2008) MathSciNetMATHCrossRefGoogle Scholar - 15.de Berg, M., Katz, M.J., van der Stappen, A.F., Vleugels, J.: Realistic input models for geometric algorithms. Algorithmica
**34**, 81–97 (2002) MathSciNetMATHCrossRefGoogle Scholar - 16.Driemel, A., Har-Peled, S., Wenk, C.: Approximating the Fréchet distance for realistic curves in near linear time. In: Proc. 26th Annu. ACM Symp. Comput. Geom., pp. 365–374 (2010). arXiv:1003.0460 Google Scholar
- 17.Efrat, A.: The complexity of the union of (
*α*,*β*)-covered objects. SIAM J. Comput.**34**(4), 775–787 (2005) MathSciNetMATHCrossRefGoogle Scholar - 18.Erickson, J.: On the relative complexities of some geometric problems. In: Proc. 7th Canad. Conf. Comput. Geom., pp. 85–90 (1995) Google Scholar
- 19.Keogh, E.J., Pazzani, M.J.: Scaling up dynamic time warping to massive dataset. In: Proc. of the Third Euro. Conf. Princip. Data Mining and Know. Disc., pp. 1–11 (1999) CrossRefGoogle Scholar
- 20.Kim, M.S., Kim, S.W., Shin, M.: Optimization of subsequence matching under time warping in time-series databases. In: Proc. ACM Symp. Appl. Comput., pp. 581–586 (2005) CrossRefGoogle Scholar
- 21.Kwong, S., He, Q.H., Man, K.F., Tang, K.S., Chau, C.W.: Parallel genetic-based hybrid pattern matching algorithm for isolated word recognition. Int. J. Pattern Recognit. Artif. Intell.
**12**(5), 573–594 (1998) CrossRefGoogle Scholar - 22.Munich, M.E., Perona, P.: Continuous dynamic time warping for translation-invariant curve alignment with applications to signature verification. In: Proc. 7th Int. Conf. Comp. Vision, pp. 108–115 (1999) CrossRefGoogle Scholar
- 23.Sriraghavendra, E., Karthik, K., Bhattacharyya, C.: Fréchet distance based approach for searching online handwritten documents. In: Proc. 9th Int. Conf. Doc. Anal. Recogn., pp. 461–465 (2007) Google Scholar
- 24.Wenk, C., Salas, R., Pfoser, D.: Addressing the need for map-matching speed: localizing global curve-matching algorithms. In: Proc. 18th Int. Conf. Sci. Statist. Database Managm., pp. 879–888 (2006) Google Scholar