Abstract 1 Introduction 2 Preliminaries 3 Approximation lower bounds for the imbalanced case 4 2-Approximation for the discrete Fréchet distance in 1D 5 (𝟑+𝜺)-approximation Algorithm for the Fréchet distance References

Fréchet Distance in the Imbalanced Case

Lotte Blank ORCID University of Bonn, Germany
Abstract

Given two polygonal curves P and Q defined by n and m vertices with mn, we show that the discrete Fréchet distance in 1D cannot be approximated within a factor of 2ε in 𝒪((nm)1δ) time for any ε,δ>0 unless OVH fails. Using a similar construction, we extend this bound for curves in 2D under the continuous or discrete Fréchet distance and increase the approximation factor to 1+2ε (resp. 3ε) if the curves lie in the Euclidean space (resp. in the L-space). This strengthens the lower bound by Buchin, Ophelders, and Speckmann to the case where m=nα for α(0,1) and increases the approximation factor of 1.001 by Bringmann. For the discrete Fréchet distance in 1D, we provide an approximation algorithm with optimal approximation factor and almost optimal running time. Further, for curves in any dimension embedded in any Lp space, we present a (3+ε)-approximation algorithm for the continuous and discrete Fréchet distance using 𝒪((n+m2)logn) time, which almost matches the approximation factor of the lower bound for the L metric.

Keywords and phrases:
Fréchet distance, SETH, Orthogonal Vectors, Lower Bounds, distance oracle, data structures
Funding:
Lotte Blank: Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – 459420781 (FOR AlgoForGe).
Copyright and License:
[Uncaptioned image] © Lotte Blank; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Computational geometry
Related Version:
Full Version: https://arxiv.org/abs/2602.09551
Editors:
Hee-Kap Ahn, Michael Hoffmann, and Amir Nayyeri

1 Introduction

The Fréchet distance is a distance metric for polygonal curves, where each curve is represented as a piecewise-linear interpolation between its vertices. There are different variants of this metric and the two most common variants are the discrete and the continuous Fréchet distance. Alt and Godau [3] were the first to study the computational complexity of the Fréchet distance. Let n and m denote the number of vertices of the two curves, which we refer to as their complexities, with nm. They showed that the continuous Fréchet distance can be computed in 𝒪(nmlogn) time. Eiter and Mannilla [21] defined the discrete Fréchet distance and gave an 𝒪(nm) time algorithm. Although both results were slightly improved later [15, 11, 1], Bringmann [6] showed that for d-dimensional curves with d2 it is very unlikely that significantly faster algorithms exists: unless the Strong Exponential Time Hypothesis (SETH) fails, no (1.001)-approximation algorithm for the continuous or discrete Fréchet distance can run in 𝒪((nm)1δ) time for any δ>0. Later, Bringmann and Mulzer [10] extended this result for the discrete Fréchet distance in 1D and increased the approximation factor up to 1.4ε for any ε>0111In [10], this result is stated only for n=m, but the same construction works for the case nm as well.. For the continuous and the discrete Fréchet distance in 1D, Buchin, Ophelders, and Speckmann [12] showed a hardness result for approximation factors up to 3ε, but only in the case where n=m. A recent result by Blank and Driemel [5] shows that the continuous Fréchet distance in 1D can indeed be computed faster when m=nα with α(0,1), namely in 𝒪(nlogn+m2log2n) time.

Related Work.

In recent years, many works have studied approximation algorithms for the Fréchet distance [18, 26, 27]. This line of research culminated in the first constant-factor approximation algorithm for the Fréchet distance that runs in subquadratic time, due to Cheng, Huang, and Zhang [17]. Their randomized (7+ε)-approximation algorithm for the continuous Fréchet distance runs in 𝒪(nm0.99log(n/ε)) time for any ε>0 and succeeds with probability at least 11/n6.

A simple idea to 3-approximate the Fréchet distance between curves where m=nα with α(0,1) in subquadratic time is the following. Compute a curve P of complexity no(n) and its distance δ to P such that every curve Q of complexity m has Fréchet distance at least δ to P. Then compute the Fréchet distance δ between P and Q. Using triangle inequality, one can show that the Fréchet distance between P and Q is at least max{δ/2,δ} and at most 3max{δ/2,δ}, which yields a 3-approximation. The difficulty of this approach is to compute such a curve P. Two related variants of this simplification problem have been studied. The first is computing an optimal m-simplification of P, that is, a curve P of complexity at most m minimizing the Fréchet distance to P among all curves of complexity at most m. The second is computing an optimal δ-simplification, that is, a curve P of minimum complexity among all curves that have Fréchet distance at most δ to P. However, no previous result achieved a subquadratic running time for curves in arbitrary dimension when the approximation factor on the complexity of the simplified curve is constant [2, 4, 7, 13, 16, 22, 28].

A different approach to reduce the running time of computing the Fréchet distance is via Fréchet distance oracles. Such an oracle is a data structure that preprocesses an input curve and subsequently answers Fréchet distance queries with respect to query curves. Driemel and Har-Peled [19] described a data structure of size 𝒪(nlogn) using 𝒪(m2lognlog(mlogn)) query time, which approximates the continuous Fréchet distance up to a (large) constant factor. For exact queries, [14] presented a data structure of size 𝒪(nm)poly(d,m) and query time in 𝒪((md)𝒪(1)log(nm)), where the query complexity m is given at preprocessing time. Blank and Driemel [5] showed that for curves in 1D, there is a data structure of size 𝒪(nlogn) that computes the continuous Fréchet distance exactly in 𝒪(m2log2n) time. For the discrete Fréchet distance, Filtser and Filtser [22] improved [20] and presented a data structure with size in 𝒪(1/ε)kdlog(ε)1 that approximates the discrete Fréchet distance within a factor of (1+ε) using expected 𝒪~(kd) query time, where 𝒪~() hides polylogarithmic factors in n. Gudmundsson, Seybold, and Wong [24] used the lower bound construction by Bringmann [6] to show in a similar fashion to [8, 20, 25] the following. In 2D, there exists no Fréchet distance oracle with poly(n) preprocessing time and 𝒪((nm)1δ) query time and approximation factor 1.001 unless SETH fails.

Table 1: Upper and Lower Bounds for the Fréchet distance Computation.
Upper Bounds
Discrete Continuous
1D 𝒪(mn) exact [21, 1] 𝒪~(mn) exact [3, 11, 15]
𝒪~(n+m2) 2-approx. Cor.20 𝒪~(n+m2) exact [5]
dD 𝒪(mn) exact [21, 1] 𝒪~(mn) exact [3, 11, 15]
𝒪~(n+m2) (3+ε)-approx. Thm.23 𝒪~(n+m2) (3+ε)-approx. Thm.23
𝒪~(nm0.99) (7+ε)-approx. [17] 𝒪~(nm0.99) (7+ε)-approx. [17]
Lower Bounds
Discrete Continuous
1D 𝒪(m2δ) (3ε)-approx. [12] 𝒪(m2δ) (3ε)-approx. [12]
𝒪~((mn)1δ) (1.4ε)-approx. [10]
𝒪~((mn)1δ) (2ε)-approx. Thm.9
2D           𝒪((mn)1δ)    (1.001)-approx.        [6]
          𝒪((mn)1δ)    (1+2ε)-approx. in L2   Thm.10
          𝒪((mn)1δ)    (3ε)-approx. in L     Thm.10

Our Results.

Our first set of results shows lower bounds for algorithms that approximate the Fréchet distance conditioned on the Orthogonal Vectors Hypothesis (OVH). We show that the discrete Fréchet distance between 1-dimensional curves cannot be (2ε)-approximated in 𝒪((nm)1δ) time for any ε,δ>0 unless OVH fails. This increases the approximation factor of 1.4ε by Bringmann and Mulzer [10]. Using a similar construction in 2D, we show that the continuous and discrete Fréchet distance cannot be approximated within a factor less than 1+2 (resp. 3) when the curves lie in the Euclidean space (resp. in the L-space) in 𝒪((nm)1δ). This leads to lower bounds for Fréchet distance oracles as well and answers an open question by [24].

To obtain this first set of results, we reduce from the Orthogonal Vector Problem: Given two sets of vectors U,V{0,1}d of size m and n, do there exist two vectors uU and vV such that u,v=0? Then, the results follow by OVH, which is implied by SETH [29, 9].

Definition 1 (Orthogonal Vectors Hypothesis (OVH)).

For all δ>0 there exists a c>0 such that there is no algorithm solving OV instances U,V{0,1}d of size m and n with mn and d=clogn in time 𝒪((nm)1δ).

We construct a curve P of complexity 𝒪(n+m) depending on V and the size of U and a curve Q of complexity 𝒪(m) depending only on U. Then, we show that the Fréchet distance between P and Q is at most 1 if and only if the OV instance has a solution. In order to get a lower bound also for the case where nm, we construct P such that the main part of P lies in a ball of radius 1. Hence, this main part can be matched to a single point of Q. Further, to obtain an inapproximability result of 2ε in 1D, the points of P and Q have integer coordinates. Hence, there are only three different values that the vertices of the main part of P can have. This significantly restricts our possibilities to define P and is the main difference to the construction by Bringmann and Mulzer [10]. They also note in their paper that obtaining a lower bound for an approximation factor of 1.4 or higher requires a significantly different construction compared to theirs.

On the positive side, we present a data structure that preprocesses a 1-dimensional curve of complexity n in 𝒪(nlogn) time using 𝒪(m) space that 2-approximates the discrete Fréchet distance to query curves of complexity m in 𝒪(m2logm) time. Hence, there exists a 2-approximation algorithm for the discrete Fréchet distance in 𝒪(nlogn+m2logm) time matching our approximation factor lower bound and essentially the time lower bound by [12]. Secondly, we match our approximation factor lower bound in the L-space by giving a simple (3+ε)-approximation algorithm for the discrete and continuous Fréchet distance using 𝒪((n+m2)logn) time for curves in any dimension under any Lp-norm. Table 1 summarizes the results of this paper and related work.

2 Preliminaries

For any two points p1,p2d, p1p2¯ denotes the directed line segment connecting p1 with p2. A polygonal curve P of complexity n is formed by ordered line segments P(i)P(i+1)¯ of points P(1),P(2),,P(n), where P(i)d. It can be viewed as a function P:[1,n]d, where P(i+α)=(1α)P(i)+αP(i+1) for i{1,,n} and α[0,1]. This curve is also denoted with P(1),,P(n). We call the points P(i) vertices and the line segments P(i)P(i+1)¯ edges of P. Further, P[s,t] is the subcurve of P obtained from restricting the domain to the interval [s,t]. Two curves P=P(1),,P(n) and Q=Q(1),,Q(m) can be composed into the curve PQ=P(1),,P(n),Q(1),,Q(m). For a number k0, define Pk be the composition of k copies of P.

Let P:[1,n]d and Q:[1,m]d be two polygonal curves. A continuous matching M between P and Q is defined by two functions hPn and hQm and consists of the tuples (hP(a),hQ(a)) for a[0,1], where n is the set of all continuous, non-decreasing functions h:[0,1][1,n] with h(0)=1 and h(1)=n, respectively m for m. Then, the (continuous) Fréchet distance between P and Q is defined as

dF(P,Q)=mincontinuous matching Mmax(x,y)MP(x)Q(y).

For a fixed δ, the free space Fδ(P,Q) is a subset of [1,n]×[1,m] such that (x,y)Fδ(P,Q) if and only if P(x)Q(y)δ. Points in ([1,n]×[1,m])Fδ(P,Q) are contained in the non-free space. Hence, the continuous Fréchet distance between P and Q is at most δ if a continuous matching MFδ(P,Q) between P and Q exists.

A discrete matching M between P and Q is an ordered sequence that starts in (1,1), ends in (n,m) and for any consecutive tuples (i,j), (i,j) in M it holds that (i,j){(i+1,j),(i,j+1),(i+1,j+1)}. Then, the discrete Fréchet distance between P and Q is

ddF(P,Q)=mindiscrete matching Mmax(i,j)MP(i)Q(j).

The free space matrix Mδ is an n×m matrix, where Mδ[i,j]=1 if |P(i)Q(j)|δ and otherwise Mδ[i,j]=0. We say that (i,j) is reachable if ddF(P[1,i],Q[1,j])δ.

Observation 2.

Let P1,P2,Q1,Q2 be curves. If dF(P1,Q1)δ and dF(P2,Q2)δ, then dF(P1P2,Q1Q2)δ. For the discrete Fréchet distance, the analogue statement holds.

Observation 3.

Let P and Q be polygonal curves, then dF(P,Q)ddF(P,Q).

3 Approximation lower bounds for the imbalanced case

In this section, we show a lower bound for the discrete Fréchet distance in 1D and for the discrete and continuous Fréchet distance in 2D depending on OVH. The construction for both bounds is very similar and we start with giving a schematic view of the reduction.

Let U,V{0,1}d be two sets of size m and n, where mn and denote with vik (resp. uik) the k-th bit of the i-th vector of V (resp. U). We construct two 1-dimensional (resp. 2-dimensional) curves P and Q of complexity 𝒪(nd) and 𝒪(md), where P depends on V and Q on U. We show that their discrete (and continuous) Fréchet distance is at most 1 if and only if two vectors that are orthogonal exist in V and U. Define

P=Ps(P)m1Pnulli=1n((P0)d+1P1=1dPviP1)Pnull(P)m1Ps,
Q=(Q)m1j=1m(QnullQc(Q1)d+1Q0=1dQujQ0Qc)Qnull(Q)m1,

where the subcurves are defined later. Since the complexity of P can be arbitrarily larger than the complexity of Q, we construct the curve P such that the main part of P, i.e., in between the two subcurves Pnull, is contained in a ball of radius 1. Then, we can match this whole part to a single point on Q. This point is Qc in our construction. At a high level idea, we want to enforce that in a matching that realizes the Fréchet distance, the two subcurves Pnull get roughly matched to different subcurves Qnull. Then, the subcurve in between the two points matched to Pnull contains (Q1)d+1 as a subcurve. Now, we enforce that (Q1)d+1 gets roughly matched to (P0)d+1. Hence, afterwards k=1dPvik and =1dQuj have to be matched together for some i and j. We will show that this is only possible if vi,uj=0. This matching is schematically visualized in Figure 1.

Figure 1: A schematic view of the construction of the curves P and Q. Here, Qnull is drawn in red, P0 and Q0 in green, P1 and Q1 in blue, and Qc in orange.

We define

Ps=(1,0), Pnull=(5,0), P=(3,0)P02d+3(3,0),
Qc=(0,0), Qnull=(4,0), Q=(2,0),(0,0),(2,0),

for 2D and the definition carries over directly to 1D. The curves P0, P1, Q0, and Q1 are visualized in Figure 2. For the 1D setting, let

P0=1,1, P1=1,0, Q0=2,1, Q1=2,2.

For the 2D constructions, define eight points with distance 1 to (0,0) where a1=(1,0) and the direction of ai+1 is the direction of ai rotated by π/4, i.e., in L2

a1=(1,0), a2=(1/2,1/2), a3=(0,1), a4=(1/2,1/2),
a5=(1,0), a6=(1/2,1/2), a7=(0,1), a8=(1/2,1/2),

and in L

a1=(1,0), a2=(1,1), a3=(0,1), a4=(1,1),
a5=(1,0), a6=(1,1), a7=(0,1), a8=(1,1).

Define c=2 and a~=a8+a7 in L2 and c=2 and a~=2a8 in L. Note that c is defined such that ca1 is the point with distance 1 to a8 and a2 that maximizes the distance to (0,0) and a~ such that a~a2=1+c and a~a8=1. Then we set

P0=a1,a2,a7,a8,a7,a1, P1=a1,a2,,a8,a1,a2,a1a8,,a1,
Q0=2a1,2a2,,2a8,ca1,2a8,,2a1, Q1=2a1,2a2,,2a7,a~,2a7,,2a1.

We show that this results in an inapproximability result of (1+cε) for time in 𝒪((nm)1δ).

Figure 2: The curves P0, P1, Q0, and Q1. The upper curves are defined in 1D, the middle curves for the L2-metric in 2D and the lower curves for the L-metric in 2D.
Lemma 4.

If there exist indices i and j such that vi,uj=0, then in every construction for P and Q above it holds that ddF(P,Q)1.

Proof.

For every construction of P and Q, it holds that ddF(P,Q)1, ddF(Ps,Q)1. Further, for x,y{0,1} with x,y=0, it holds that ddF(Px,Qy)1. Then, we can match the following with Fréchet distance at most 1 and the lemma follows by Observation 2

Ps(P)mj and (Q)m1,
(P)j1Pnull and k=1j1(QnullQc(Q1)d+1Q0
=1dQukQ0Qc)Qnull,
k=1i1((P0)d+1P1=1dPvkP1) and Qc,
(P0)d+1P1=1dPviP1 and (Q1)d+1Q0=1dQujQ0,
k=i+1n((P0)d+1P1=1dPvkP1) and Qc,
Pnull(P)mj and k=j+1m(QnullQc(Q1)d+1Q0
=1dQukQ0Qc)Qnull,
(P)j1Ps and (Q)m1.

To show the other direction, we first prove some lemmas.

Lemma 5.

Consider the 1D setting and let Q==1dQσ, where σ{0,1} for every . Further, let st be such that P[s,t] is a subcurve in between the two subcurves Pnull and ddF(Q,P[s,t])<2. Then P[s,t]==1dPπ where π=0 if σ=1 and π{0,1} if σ=0 for every .

Proof.

It holds that every second vertex of Q is 2 and the vertices of value 1 on P[s,t] are the only vertices on P[s,t] within distance less than 2 to those vertices of Q. Further, it holds that the vertices with value 1 of P[s,t] have distance less than two only to the vertices of value 2 of Q. Hence, since the vertices of value 1 on P[s,t] are exactly every second vertex on P[s,t], we must traverse P[s,t] and Q synchronously. Therefore, if σ=0 then π{0,1} and if σ=1 then π=0 by construction.

In 2D, we also want to show a bound for the continuous Fréchet distance. Then the vertices of Q can also be matched to points on edges of P. We use the notation of the following subcurve of P0 (resp. P1): P0=a4,a5,,a8,,a4 (resp. P1=a4,,a8,a1,a2,a1,a8,,a4).

Lemma 6.

Consider the 2D setting. For any subcurve P of P in between the two subcurves Pnull with dF(P,Qy)<1+c for y{0,1}, it holds that Px is a subcurve of P and P is a subcurve of a4,a3,a2Pxa2,a3,a4, where x=0 if y=1 and x{0,1} if y=0.

Figure 3: In white: the non-free space of the curve Q0 and P0P0P1 on the left and of the curve Q1 and P0P0P1 on the right. The red, orange and pink paths visualize the proof of Lemma 6.

Proof.

We show this lemma by constructing paths in the non-free space for δ=1+c (see Figure 3). First observe that 2aiaj1+c for any i,j{1,,8} with ij3mod8.

Assume that the first (resp. last) vertex of Qy is matched to a point on a subcurve Px with x{0,1}. Then, there must exist a path completely contained in the free space ending at the last (resp. first) vertex of Qy. This cannot be the case since there exists a continuous matching between Px and 2a1,2a2,2a5,,2a1 that is completely contained in the non-free space (see the red paths in Figure 3). Therefore, the first as well as the last vertex of Qy has to be matched to a point on a subcurve P′′ of P such that P′′=a4,a3,a2,a1,a2,a3,a4.

Next, we show that P contains exactly one Px as a subcurve. Since ca1a51+c (resp. a~a51+c), there exists a path that is completely contained in the non-free space between a5,a4,a2,a1,a2,,a4,a5 and 2a8,ca1,2a8,2a7,,2a4,2a5,,2a8,ca1,2a8(resp. a~,2a7,,2a4,2a5,,a~) (see the orange paths in Figure 3). Hence by construction of P, it follows that Px is a subcurve of P and P is a subcurve of a4,a3,a2Pxa2,a3,a4 with x{0,1}. It remains to show that x1, if y=1. This follows since the distance between a2 and 2a7, a~, 2a7 is at least 1+c (see the pink path in Figure 3). The next lemma follows directly by the construction of the curves and Lemma 6.

Lemma 7.

Consider the 2D setting and let Q==1dQσ, where σ{0,1} for every . Further, let st be such that P[s,t] is a subcurve in between the two subcurves Pnull and dF(Q,P[s,t])<1+c. Then, Pπ1=2d1PπPπd is a subcurve of P[s,t] and P[s,t] is a subcurve of a4,a3,a2=1dPπa2,a3,a4 where π=0 if σ=1 and π{0,1} if σ=0 for every .

Lemma 8.

If ddF(P,Q)<2 (resp. dF(P,Q)<1+c) in the 1D (resp. 2D) construction, then there exist two indices i and j such that vi,uj=0.

Proof.

Let M be a discrete (resp. continuous) matching that realizes the discrete (resp. continuous) Fréchet distance between P and Q. Assume that dF(P,Q)<2 (resp. ddF(P,Q)<1+c), then in the matching M, the two points of value Pnull of P must be matched to two distinct points q1,q2 on Q both on an edge that contains the value Qnull, since they are the only points within distance at most 1+c3 to Pnull. Let P0=P0 and P1=P1 in the 1D setting. Define j such that q1 is contained on an incident edge to the j-th Qnull on Q. Then, the first (Q1)d+1 after the j-th Qnull on Q must be matched to a subcurve P of P such that P1(P0)d+1P1 is a subcurve of P by Lemma 5 and Lemma 7. The only time we have (P0)d+1 in P is before P1=1dPvi for an i. Hence by Lemma 5 and Lemma 7, there exists an index i such that in the matching M the subcurve Pvi,1=2d1Pvi,Pvi,d is matched to a subcurve of =1dQuj, and vi,=0 if uj,=1. Hence, it holds that vi,uj=0. By Lemma 4 and Lemma 8 together with Observation 3, the next two theorems follow.

Theorem 9.

For any δ,ε>0, there does not exist a (2ε)-approximation algorithm for the discrete Fréchet distance between 1-dimensional curves of complexity n and m using 𝒪((nm)1δ) time unless OVH fails.

Theorem 10.

For any δ,ε>0, there does not exist a (kε)-approximation algorithm for the continuous or discrete Fréchet distance between 2-dimensional curves of complexity n and m using 𝒪((nm)1δ) time unless OVH fails, where k=3 (resp. k=1+22.41) if the curves lie in the L-space (resp. in the Euclidean space).

Our construction gives also a bound on Fréchet distance oracles (proof in the full version).

Theorem 11.

Assume OVH holds true. For any δ>0, there exists a c>0 such that for any n and m>clogn there is no data structure storing a curve of complexity n with poly(n) preprocessing time, that when given a query curve of at most complexity m can answer continuous or discrete Fréchet distance queries in 𝒪((nm)1δ) query time within the same approximation factor as in Theorem 9 and Theorem 10.

4 2-Approximation for the discrete Fréchet distance in 1D

Given a value m and a 1-dimensional curve P of complexity nm. We want to preprocess P in near-linear time and store information about P using 𝒪(m) space such that for any 1-dimensional query curve Q of complexity at most m we can approximate the discrete Fréchet distance between P and Q in 𝒪(m2logm) time.

Preprocessing.

Define δm=min{ddF(P,Q)Q has complexity m}. We want to compute a curve P such that ddF(P,P)δm/2. The complexity of P might be n, but it should be possible to store a compact description of P in 𝒪(m) space. To compute P, we first compute the optimal m-simplification P of P for the discrete Fréchet distance. The curve P is computed via searching over the possible values δ for δm and then computing the optimal δ-simplification. We compute the optimal δ-simplification of P using Algorithm 1. It begins by finding the longest prefix P[1,i1] that is contained in a 2δ-interval, whose center becomes the first vertex of the δ-simplification. Then, it continues by finding the largest index i2 such that P[i1+1,i2] is contained in a 2δ-interval and again the center of this interval is added to the δ-simplification. This process is repeated until the final vertex of P is reached.

Algorithm 1 Optimal δ-simplification of P.

The proof of the following lemma is in the full version.

Lemma 12.

Algorithm 1 computes an optimal δ-simplification Pδ of P using 𝒪(n) time.

If the complexity of the δ-simplification is greater than m, it holds that δm>δ. Otherwise, δmδ. In contrast to higher dimensions, the optimal m-simplification for any m of a 1-dimensional curve P has distance δm{|P(i)P(j)|/2i,j{1,,n}} to P, where the distance is only defined by two vertices of P. By Frederickson and Johnson [23], we can search over all possible values for δm using 𝒪(logn) calls of Algorithm 1 and get the following lemma.

Lemma 13.

We can compute an optimal m-simplification P of P together with a discrete matching that realizes the discrete Fréchet distance between P and P in 𝒪(nlogn) time.

Figure 4: The black curve is P and the middle curve is an optimal 3-simplification for P. The red curve below is the compressed curve P. Here, k1=3, k2=7, k3=3 and z1=1, z2=1, z3=1.

Let P=p1,,p be an optimal m-simplification of P. Let M be the discrete matching between P and P computed by Algorithm 1, and P(ij) be the last vertex of P that is matched to pj; i.e. M=((1,1),(2,1),(i1,1), (i1+1,2),(i1+2,2),,(i2,2),(i2+1,3),,(i,)). We construct a curve P that has discrete Fréchet distance at most δm/2 to P and can be stored in a compressed way using 𝒪(m) space (see Figure 4). We call P a compressed simplification. For every (x,y)M, define rx=pyδm/2 if P(x)<py and rx=py+δm/2 otherwise. Then, it holds that |rxP(x)|δm/2. The compressed simplification P is r1,,rn after deleting the vertices with identical predecessor, so that P contains ri only if riri1. For every j, we count the total number kj that P contains pj±δm/2 and define zj{1,1} such that the first time P contains pj+zjδm/2 is before P contains pjzjδm/2. Therefore, the values p1,,p, k1,,k, z1,,z, and δm fully describe P. The next lemma follows directly by construction and m.

Lemma 14.

Given P and its optimal m-simplification P, we can compute in 𝒪(n) time a curve P such that ddF(P,P)δm/2 and P can be stored using 𝒪(m) space.

The Query Algorithm.

In the following, we give a 2-approximation query algorithm for the discrete Fréchet distance between P and any query curve Q of complexity m. We use the precomputed compressed simplification P and compute ddF(P,Q) if it is at least 32δm.

Lemma 15.

If ddF(P,Q)32δm, then ddF(P,Q)[δm,2δm]. Otherwise, define δ such that 32δ=ddF(P,Q). Then, ddF(P,Q)[δ,2δ).

Proof.

By definition of δm, it holds that ddF(P,Q)δm for every curve Q of complexity m. Further, by Lemma 14 it holds that ddF(P,P)δm/2. Hence, if ddF(P,Q)32δm, then

δmddF(P,Q)ddF(P,Q)+ddF(P,P)32δm+12δm2δm.

Otherwise, it holds that 32δ=ddF(P,Q)>32δm. Hence, δ>δm. Therefore,

δ<32δ12δmddF(P,Q)ddF(P,P)ddF(P,Q)ddF(P,Q)+ddF(P,P)<2δ.

Using Lemma 15, we could simply compute ddF(P,Q) to get a 2-approximation algorithm for ddF(P,Q). However, computing ddF(P,Q) with known discrete Fréchet distance algorithms takes roughly 𝒪(mi=1ki) time and i=1ki could be n. In the following, we make use of the special structure of P to get a faster algorithm that decides whether ddF(P,Q)32δ for any value δδm. We use the concept of the free space matrix M(3/2)δ, but do not compute all reachable entries explicitly. Define si=j=1i1kj+1 to be the index of the first vertex with value pi±δm/2 in P and s+1=|P|+1. Algorithm 2 iterates over the sub-curves P[si,si+11] of P from i=1 to and stores in the set Fpre the indices j of the vertices of Q such that (si1,j) is reachable (see the hatched cells in Figure 5). Using Fpre, in iteration i we successively compute the set Fnew of indices such that (si+11,j) is reachable and make use of the following property.

Observation 16.

For any point q, it holds that exactly one of the following is true:

  • |qpi|δ and |qP(si+x)|32δ for all x{0,,ki1}, or

  • |qpi|(δ,2δ] and |qP(si+x)|32δ for all even (resp. odd) x{0,,ki1} and |qP(si+x)|>32δ for all odd (resp. even) x{0,,ki1}, or

  • |qpi|>2δ.

By Observation 16, it holds that whenever |Q(j)pi|δ, there exists an number a such that (si+x,j) with x{0,,ki1} is reachable if and only if xa and whenever |Q(j)pi|>2δ, then (si+x,j) is not reachable for any integer x{0,,ki1} and we set a=. When |Q(j)pi|(δ,2δ], things get slightly more complicated. However, we can still store a number a such that (si+x,j) is reachable for all x{a,a+2,} with xki1. Since there might be more reachable pairs (si+x,j), we store a set A of size at most m and a number u which can be used to reconstruct all other reachable pairs (si+x,j) with x{0,,a}. Then, let B{0,,min{ki1,a}} be the set such that for all xmin{ki1,a} it holds that (si+x,j1) is reachable if and only if xB. It holds that B only if |Q(j1)pi|(δ,2δ]. In that case, define z=0 (resp. z=1) if Q(j1) and Q(j) lie on the same side (resp. different sides) of pi. Then for any x+z>0, it holds that that (si+x+z,j1) is reachable if and only if xB. Using this property, we store a counter u that counts the sum of the values z until we reach again a vertex with |Q(j)pi|(δ,2δ]. If x+z=0, we additionally check whether (si1,j1) or (si1,j) is reachable by looking at the set Fpre. If one of them is reachable, then (si,j1)=(si+(uu),j) is reachable and we add the current number u to the stored set A. In short, we intend to maintain the following invariant. During iteration i of the outer for-loop and at the end of iteration j of the inner for-loop, it holds that (si+x,j) is reachable with x{0,,ki1} if and only if

a) x{uzzA}{a} or b) x>a and |Q(j)P(si+x)|(2/3)δ.

See Figure 5 for an example. Here, during iteration i=3 of the outer for-loop and at the end of iteration j=7 (resp. j=8) of the inner for-loop, it holds that A=[0,2], u=2, and a= (resp. A=[], u=0, and a=0).

Algorithm 2 Decision Algorithm for ddF(P,Q)32δ.
Figure 5: The compressed curve P and the query curve Q are on the left. On the right is the free space matrix of P and Q, where only 1-entries are added. The dark green cells visualize the parameter a and the light green cells the set {uzzA}. The hatched cells are the cells that have been in Fpre and Fnew.
Lemma 17.

Assume that at the beginning of iteration i of the outer for-loop after setting FpreFnew, it holds (si1,j) is reachable if and only if jFpre. Then, at the end of iteration i it holds that (si+11,j) is reachable if and only if jFnew.

Proof.

Denote with Aj, aj, and uj the value of A, a, and u at the end of iteration j in the inner for-loop of Algorithm 2. Then, we show that the following invariant is true; for every x{0,,ki1}, it holds that (si+x,j) is reachable if and only if

a) x{ujzzAj}{aj} or b) x>aj and |Q(j)P(si+x)|(2/3)δ.

We prove this invariant via induction on j. For j=0, the invariant clearly holds as {ujzzAj}{aj}={}. Now assume the invariant holds for j1. Let x{0,,ki1}. Then, by definition of the discrete Fréchet distance (si+x,j) is reachable if and only if |Q(j)P(si+x)|23δ and (si+x1,j), (si+x,j1), or (si+x1,j1) is reachable. We consider three different cases.

  1. 1.

    If |Q(j)pi|>2δ, then (si+x,j) is not reachable, since |Q(j)P(si+x)|>23δ. By line 5 of Algorithm 2, the invariant holds.

  2. 2.

    If |Q(j)pi|δ, then |Q(j)P(si+x)|23δ for any x{0,,ki1}. Further, observe that if (si+y,j) is reachable for y{0,,ki1}, then (si+x,j) is also reachable for every yxki1. Define y{0,,ki1} to be the minimum such that (si+y,j) is reachable. Hence, by line 13 it holds that the invariant holds if aj=y. Unless y=0 and (si1,j) or (si1,j1) is reachable, it must hold that (si+y,j1) is reachable as otherwise y would not be the minimum. Further again since y is the minimum and by the invariant for j1, it holds that y=min{uj1zzAj1}{aj1}. Now, consider the special case that y=0 and (si1,j), or (si1,j1) is reachable. By assumption, it holds that (si1,j) (resp. (si1,j1)) is reachable if and only if jFpre (resp. j1Fpre). Hence, aj is set to y by line 912 and the invariant is true.

  3. 3.

    It remains the case that δ<|Q(j)pi|2δ.

    1. (a)

      First, consider the case that xaj1. Then since (si+aj1,j1) is reachable by the induction hypothesis, it holds that |Q(j1)pi|2δ. Hence, |Q(j1)P(si+x)|23δ or |Q(j1)P(si+x1)|23δ. Further again by the induction hypothesis it holds that (si+x,j1) or (si+x1,j1) is reachable. Hence, by line 78 the invariant holds for xaj1.

    2. (b)

      Otherwise, it holds that x<aj1. Consider the special case that x=0 and (si+x,j) is reachable because |Q(j)P(si+x)|23δ and (si1,j) or (si1,j1) are reachable. Then by 9 and the assumption on Fpre, it holds that ujAj. Otherwise it holds that (si+x,j) is reachable if and only if (si+x,j1) or (si+x1,j1) is reachable and |Q(j)pi|32δ. This is true because it holds that either |Q(j)P(si+x)|23δ or |Q(j)P(si+x1)|23δ since δ<|Q(j)pi|2δ. Hence, x1Aj1 or xAj1. Therefore, Aj1[] and by the algorithm it holds that δ<|Q(j1)pi|2δ. If min{Q(j1),Q(j)}>pi or max{Q(j1),Q(j)}<pi, then (si+x,j) is reachable if and only if (si+x,j1) is reachable by Observation 16. Otherwise (si+x,j) is reachable if and only if (si+x1,j1) is reachable. This is ensured by line 78.

This proves that the invariant is true for every j. Note that (si+11,j)=(si+ki1,j). By the invariant it holds that (si+ki1,j) is reachable if and only if |P(si+11)Q(j)|32δ and aj<ki or ujki+1Aj. Hence the lemma follows by line 1516.

Lemma 18.

For any value δδm, we can decide whether ddF(P,Q)32δ in 𝒪(m) time.

Proof.

We run Algorithm 2 and output ddF(P,Q)32δ if and only if mFnew at the end of Algorithm 2. The running time of Algorithm 2 is in 𝒪(m), since the array A is sorted and in every iteration of the inner for loop at most one point gets appended to A. By induction on the index i of si and Lemma 17, it holds that (|P|,m)=(s+11,m) is reachable if and only if ddF(P,Q)32δ.

It remains to optimize the δ value. First, we decide whether ddF(P,Q)32δm or not using Algorithm 2. If ddF(P,Q)32δm, then ddF(P,Q)[δm,2δm] by Lemma 15 and δm is a 2-approximation for ddF(P,Q). Otherwise ddF(P,Q)>32δm. In this case, we use the observation that the discrete Fréchet distance between P and Q gets realizes by a point to point distance between a vertex of P and a vertex of Q. Hence,

ddF(P,Q){|(pi±δ/2)Q(j)|i{1,,},j{1,,m}}.

We sort these values in 𝒪(m2logm) time and search over the ones that are greater 32δm. Using Algorithm 2, we compute in 𝒪(m2logm) time 32δ=ddF(P,Q). Then, it holds that ddF(P,Q)[δ,2δ] by Lemma 15. Therefore, we get the following theorem:

Theorem 19.

For a given value m, there exists a data structure that preprocesses a 1-dimensional curve P of complexity n in 𝒪(nlogn) time using 𝒪(m) space such that for any 1-dimensional query curve Q of complexity at most m, we can approximate the discrete Fréchet distance between P and Q within a factor of 2 in 𝒪(m2logm) time.

The next corollary is a direct consequence of the theorem above.

Corollary 20.

Given two 1-dimensional curves P and Q of complexity n and m with nm. There exists a 2-approximation algorithm to compute the discrete Fréchet distance between P and Q in 𝒪(nlogn+m2logm) time.

By Theorem 9, it follows that there does not exist an algorithm using 𝒪(nlogn+m2logm) time with a better approximation factor. Further, the lower bound in [12] shows the almost optimality of the running time.

5 (𝟑+𝜺)-approximation Algorithm for the Fréchet distance

In this section, we give a (3+ε)-approximation algorithm to compute the continuous/discrete Fréchet distance between two curves P and Q of complexity n resp. m with mn. We describe this section for the continuous Fréchet distance, but everything works analogously for the discrete Fréchet distance as well. We begin with the decision variant for δ. In the first step, using the curve Q, we compute a curve P of complexity at most 2m such that dF(P,P)δ or decide that dF(P,Q)>δ in linear time.

Lemma 21.

Algorithm 3 computes a curve P of complexity at most 2m with dF(P,P)δ or returns dF(P,Q)>δ in 𝒪(n) time.

Proof.

In the i-th iteration of the while-loop, it holds that sii by line 3 of Algorithm 3. Further, it holds that aiai+1 for every i and line 6 has running time 𝒪(ai+1ai) as Q(si)Q(ti)¯Q(si)Q(si+1)¯. Hence, the running time follows. If a curve P is returned, it holds that dF(P,P)δ by line 6 and Observation 2. The complexity of P is at most 2m since there are at most m iterations of the while loop. It remains to show correctness for the case when dF(P,Q)>δ is returned. Assume that dF(P,Q)>δ is returned and in fact it holds dF(P,Q)δ. Let M be the matching between P and Q that realizes the Fréchet distance. We consider two cases (see Figure 6). In the first case, there exist b,b and an index i such that (b,si),(b,ti)M with bai and b>ai+1. This contradicts line 6 of the algorithm. Otherwise, there must exist an index i and a parameter c such that (ai,c)M with ti1c<si. This contradicts line 3. Hence, it follows that dF(P,Q)>δ.

Figure 6: The green curve is a matching between the curves P[ai,ai+1] and Q[si,ti] computed in Algorithm 3. The blue curves visualize the matching used in the proof of Lemma 21.
Algorithm 3 Simplification of P depending on Q.

Lemma 21 can be easily adapted such that it holds for the discrete Fréchet distance. Given P, we decide whether dF(P,Q)2δ in 𝒪(m2) time [3] or slightly faster [15]. If dF(P,Q)2δ, then dF(P,Q)dF(P,Q)+dF(P,P)3δ. Otherwise, it holds that dF(P,Q)dF(P,Q)dF(P,P)>δ. Hence, we obtain the following lemma.

Lemma 22.

Given two curves P and Q of complexity n and m in any metric space M. Assume that we can compute distances in M in constant time. We can 3-approximate the decision variant of the continuous/discrete Fréchet distance in 𝒪(n+m2) time.

For curves in the Euclidean space, Colombe and Fox (Theorem 11 of [18]) show how to transform a decision algorithm into an approximate optimization algorithm increasing the running time by a 𝒪(log(n/ε)) factor. Since all Lp-norms on d are equivalent and Lemma 22 holds for all Lp-norms, we can adopt their approach such that we can use it for all Lp-norms.

Theorem 23.

There exist a (3+ε)-approximation algorithm for the continuous/discrete Fréchet distance using 𝒪((n+m2)log(n/ε)) time.

References

  • [1] Pankaj K. Agarwal, Rinat Ben Avraham, Haim Kaplan, and Micha Sharir. Computing the discrete Fréchet distance in subquadratic time. SIAM Journal on Computing, 43(2):429–449, 2014. doi:10.1137/130920526.
  • [2] Pankaj K. Agarwal, Sariel Har-Peled, Nabil H. Mustafa, and Yusu Wang. Near-linear time approximation algorithms for curve simplification. Algorithmica, 42(3-4):203–219, 2005. doi:10.1007/S00453-005-1165-Y.
  • [3] Helmut Alt and Michael Godau. Computing the Fréchet distance between two polygonal curves. Int. J. Comput. Geom. Appl., 5:75–91, 1995. doi:10.1142/S0218195995000064.
  • [4] Sergey Bereg, Minghui Jiang, Wencheng Wang, Boting Yang, and Binhai Zhu. Simplifying 3d polygonal chains under the discrete Fréchet distance. In Eduardo Sany Laber, Claudson F. Bornstein, Loana Tito Nogueira, and Luérbio Faria, editors, LATIN 2008: Theoretical Informatics, 8th Latin American Symposium, Búzios, Brazil, April 7-11, 2008, Proceedings, volume 4957 of Lecture Notes in Computer Science, pages 630–641. Springer, 2008. doi:10.1007/978-3-540-78773-0_54.
  • [5] Lotte Blank and Anne Driemel. A faster algorithm for the Fréchet distance in 1d for the imbalanced case. In Timothy M. Chan, Johannes Fischer, John Iacono, and Grzegorz Herman, editors, 32nd Annual European Symposium on Algorithms, ESA 2024, September 2-4, 2024, Royal Holloway, London, United Kingdom, volume 308 of LIPIcs, pages 28:1–28:15. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPIcs.ESA.2024.28.
  • [6] Karl Bringmann. Why walking the dog takes time: Fréchet distance has no strongly subquadratic algorithms unless seth fails. In 2014 IEEE 55th Annual Symposium on Foundations of Computer Science, pages 661–670. IEEE, 2014. doi:10.1109/FOCS.2014.76.
  • [7] Karl Bringmann and Bhaskar Ray Chaudhury. Polyline simplification has cubic complexity. In Gill Barequet and Yusu Wang, editors, 35th International Symposium on Computational Geometry, SoCG 2019, June 18-21, 2019, Portland, Oregon, USA, volume 129 of LIPIcs, pages 18:1–18:16. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPIcs.SOCG.2019.18.
  • [8] Karl Bringmann, Anne Driemel, André Nusser, and Ioannis Psarros. Tight bounds for approximate near neighbor searching for time series under the Fréchet distance. In Joseph (Seffi) Naor and Niv Buchbinder, editors, Proceedings of the 2022 ACM-SIAM Symposium on Discrete Algorithms, SODA 2022, Virtual Conference / Alexandria, VA, USA, January 9 - 12, 2022, pages 517–550. SIAM, 2022. doi:10.1137/1.9781611977073.25.
  • [9] Karl Bringmann and Marvin Künnemann. Multivariate fine-grained complexity of longest common subsequence. In Artur Czumaj, editor, Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018, pages 1216–1235. SIAM, 2018. doi:10.1137/1.9781611975031.79.
  • [10] Karl Bringmann and Wolfgang Mulzer. Approximability of the discrete Fréchet distance. Journal of Computational Geometry, 7(2):46–76, 2016. doi:10.20382/JOCG.V7I2A4.
  • [11] Kevin Buchin, Maike Buchin, Wouter Meulemans, and Wolfgang Mulzer. Four soviets walk the dog: Improved bounds for computing the Fréchet distance. Discrete Comput. Geom., 58(1):180–216, July 2017. doi:10.1007/s00454-017-9878-7.
  • [12] Kevin Buchin, Tim Ophelders, and Bettina Speckmann. SETH says: Weak Fréchet distance is faster, but only if it is continuous and in one dimension. In Timothy M. Chan, editor, Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2019, San Diego, California, USA, January 6-9, 2019, pages 2887–2901. SIAM, 2019. doi:10.1137/1.9781611975482.179.
  • [13] Siu-Wing Cheng and Haoqiang Huang. Curve simplification and clustering under Fréchet distance. In Nikhil Bansal and Viswanath Nagarajan, editors, Proceedings of the 2023 ACM-SIAM Symposium on Discrete Algorithms, SODA 2023, Florence, Italy, January 22-25, 2023, pages 1414–1432. SIAM, 2023. doi:10.1137/1.9781611977554.CH51.
  • [14] Siu-Wing Cheng and Haoqiang Huang. Solving Fréchet distance problems by algebraic geometric methods. In David P. Woodruff, editor, Proceedings of the 2024 ACM-SIAM Symposium on Discrete Algorithms, SODA 2024, Alexandria, VA, USA, January 7-10, 2024, pages 4502–4513. SIAM, 2024. doi:10.1137/1.9781611977912.158.
  • [15] Siu-Wing Cheng and Haoqiang Huang. Fréchet distance in subquadratic time. In Yossi Azar and Debmalya Panigrahi, editors, Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2025, New Orleans, LA, USA, January 12-15, 2025, pages 5100–5113. SIAM, 2025. doi:10.1137/1.9781611978322.173.
  • [16] Siu-Wing Cheng, Haoqiang Huang, and Le Jiang. Simplification of trajectory streams. In Oswin Aichholzer and Haitao Wang, editors, 41st International Symposium on Computational Geometry, SoCG 2025, June 23-27, 2025, Kanazawa, Japan, volume 332 of LIPIcs, pages 34:1–34:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025. doi:10.4230/LIPIcs.SOCG.2025.34.
  • [17] Siu-Wing Cheng, Haoqiang Huang, and Shuo Zhang. Constant approximation of Fréchet distance in strongly subquadratic time. In Michal Koucký and Nikhil Bansal, editors, Proceedings of the 57th Annual ACM Symposium on Theory of Computing, STOC 2025, Prague, Czechia, June 23-27, 2025, pages 2329–2340. ACM, 2025. doi:10.1145/3717823.3718157.
  • [18] Connor Colombe and Kyle Fox. Approximating the (continuous) Fréchet distance. In Kevin Buchin and Éric Colin de Verdière, editors, 37th International Symposium on Computational Geometry, SoCG 2021, June 7-11, 2021, Buffalo, NY, USA (Virtual Conference), volume 189 of LIPIcs, pages 26:1–26:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.SOCG.2021.26.
  • [19] Anne Driemel and Sariel Har-Peled. Jaywalking your dog: Computing the Fréchet distance with shortcuts. SIAM J. Comput., 42(5):1830–1866, 2013. doi:10.1137/120865112.
  • [20] Anne Driemel, Ioannis Psarros, and Melanie Schmidt. Sublinear data structures for short Fréchet queries. CoRR, abs/1907.04420, 2019. arXiv:1907.04420.
  • [21] Thomas Eiter and Heikki Mannila. Computing discrete Fréchet distance, 1994.
  • [22] Arnold Filtser and Omrit Filtser. Static and streaming data structures for Fréchet distance queries. ACM Trans. Algorithms, 19(4):39:1–39:36, 2023. doi:10.1145/3610227.
  • [23] Greg N. Frederickson and Donald B. Johnson. Generalized selection and ranking: Sorted matrices. SIAM J. Comput., 13(1):14–30, 1984. doi:10.1137/0213002.
  • [24] Joachim Gudmundsson, Martin P. Seybold, and Sampson Wong. Map matching queries on realistic input graphs under the Fréchet distance. ACM Trans. Algorithms, 20(2):14, 2024. doi:10.1145/3643683.
  • [25] Aviad Rubinstein. Hardness of approximate nearest neighbor search. In Ilias Diakonikolas, David Kempe, and Monika Henzinger, editors, Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2018, Los Angeles, CA, USA, June 25-29, 2018, pages 1260–1268. ACM, 2018. doi:10.1145/3188745.3188916.
  • [26] Thijs van der Horst and Tim Ophelders. Faster Fréchet distance approximation through truncated smoothing. CoRR, abs/2401.14815, 2024. doi:10.48550/arXiv.2401.14815.
  • [27] Thijs van der Horst, Marc J. van Kreveld, Tim Ophelders, and Bettina Speckmann. A subquadratic nϵ-approximation for the continuous Fréchet distance. In Nikhil Bansal and Viswanath Nagarajan, editors, Proceedings of the 2023 ACM-SIAM Symposium on Discrete Algorithms, SODA 2023, Florence, Italy, January 22-25, 2023, pages 1759–1776. SIAM, 2023. doi:10.1137/1.9781611977554.CH67.
  • [28] Marc J. van Kreveld, Maarten Löffler, and Lionov Wiratma. On optimal polyline simplification using the Hausdorff and Fréchet distance. In Bettina Speckmann and Csaba D. Tóth, editors, 34th International Symposium on Computational Geometry, SoCG 2018, June 11-14, 2018, Budapest, Hungary, volume 99 of LIPIcs, pages 56:1–56:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2018. doi:10.4230/LIPIcs.SOCG.2018.56.
  • [29] Ryan Williams. A new algorithm for optimal 2-constraint satisfaction and its implications. Theor. Comput. Sci., 348(2-3):357–365, 2005. doi:10.1016/J.TCS.2005.09.023.