The Geodesic Fréchet Distance Between Two Curves Bounding a Simple Polygon
Abstract
The Fréchet distance is a popular similarity measure that is well-understood for polygonal curves in : near-quadratic time algorithms exist, and conditional lower bounds suggest that these results cannot be improved significantly, even in one dimension and when approximating with a factor less than three. We consider the special case where the curves bound a simple polygon and distances are measured via geodesics inside this simple polygon. Here the conditional lower bounds do not apply; Efrat et al. (2002) were able to give a near-linear time -approximation algorithm.
In this paper, we significantly improve upon their result: we present a -approximation algorithm, for any , that runs in time for a simple polygon bounded by two curves with and vertices, respectively. To do so, we show how to compute the reachability of specific groups of points in the free space at once, by interpreting the free space as one between separated one-dimensional curves. We solve this one-dimensional problem in near-linear time, generalizing a result by Bringmann and Künnemann (2015). Finally, we give a linear time exact algorithm if the two curves bound a convex polygon.
Keywords and phrases:
Fréchet distance, approximation, geodesic, simple polygonFunding:
Tim Ophelders: partially supported by the Dutch Research Council (NWO) under project no. VI.Veni.212.260.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Computational geometryEditors:
Anne Benoit, Haim Kaplan, Sebastian Wild, and Grzegorz HermanSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The Fréchet distance is a well-studied similarity measure for curves in a metric space. Most results so far concern the Fréchet distance between two polygonal curves and in with and vertices, respectively. Then the Fréchet distance between two such curves can be computed in time (see e.g. [1, 5]). There is a closely matching conditional lower bound: If the Fréchet distance between polygonal curves can be computed in time (for any constant ), then the Strong Exponential Time Hypothesis fails [3]. This lower bound extends to curves in one dimension, and holds even when approximating to a factor less than three [6].
Because it is unlikely that exact strongly subquadratic algorithms exist, approximation algorithms have been developed [9, 15, 8]. The authors [15] were the first to present an algorithms which results in an arbitrarily small polynomial approximation factor ( for any ) in strongly subquadratic time (). Very recently, Cheng et al. [8] gave the first (randomized) constant-factor approximation algorithm with a strongly subquadratic running time. Specifically, it computes a -approximation in time.
For certain families of “realistic” curves, the SETH lower bound does not apply. For example, when the curves are -packed, Driemel et al. [11] gave an -approximation algorithm, for any , that runs in time. Bringmann and Künnemann [4] improved the running time to time.
For curves in one dimension with an imbalanced number of vertices, the Fréchet distance can be computed in strongly subquadratic time without making extra assumptions about the shape of the curves. This was recently established by Blank and Driemel [2], who give an -time algorithm when for some .
If the two polygonal curves and lie inside a simple polygon with vertices and we measure distances by the geodesic distance inside , then neither the upper nor the conditional lower bound change in a fundamental way. Specifically, Cook and Wenk [10] show how to compute the Fréchet distance in this setting in time, with . For more general polygonal obstacles, Chambers et al. [7] give an algorithm that computes the homotopic Fréchet distance in time, where is the total number of vertices on the curves and obstacles.
Har-Peled et al. [13] investigate the setting where and are simple, interior-disjoint curves on the boundary of a triangulated topological disk. If the disk has faces, their algorithm computes a -approximation to the homotopic Fréchet distance in time. Efrat et al. [12] consider a more geometric setting, where and bound a simple polygon (see Figure 1 (left)). Here, the SETH lower bound does not apply; a -approximation to the geodesic Fréchet distance can be computed in time [12]. Moreover, the authors [14] recently gave an -time exact algorithm for a similar setting, where distances are measured under the -geodesic distance. Their result implies a -approximation algorithm for the geodesic Fréchet distance.
Organization and results.
In this paper, we significantly improve upon the results of Efrat et al. [12] and the authors [14]: we present a -approximation algorithm for the geodesic Fréchet distance, for any , that runs in time when and together bound a simple polygon. We give an overview of our algorithm in Section 2. Our algorithm relies on an interesting connection between matchings and nearest neighbors and is described in Section 3. There we also explain how to transform the decision problem for far points on (those who are not a nearest neighbor of any point on ) into a problem between separated one-dimensional curves. This problem is about computing, given a set of “entrances” and “potential exits” (points anywhere in the parameter space), which potential exits are -reachable from entrances. Bringmann and Künnemann [4] study a restricted variant of this problem in the context of Fréchet distance between -packed curves. In addition to giving a near-linear time algorithm for the general problem, we also compute the Fréchet distance between two separated one-dimensional curves in linear time.
In the full version of this paper, we additionally describe a simple linear-time algorithm for when is a convex polygon. We show that in this setting there is a Fréchet matching with a specific structure: a maximally-parallel matching (see Figure 1 (right)). We compute the orientation of the parallel part from up to different tangents, which we find using “rotating calipers.”
Preliminaries.
A (polygonal) curve with vertices is a continuous map that is linear on each interval where is an integer. Its vertices are the points . If the vertices lie in the plane, then we say is two-dimensional.111Curves are inherently one-dimensional objects. We abuse terminology slightly to refer to the ambient dimension as the dimension of a curve. A one-dimensional curve is defined analogously.
We denote by the subcurve of over the domain , and abuse notation slightly to let to also denote this subcurve when and . The edges of are the directed line segments for integers . We write to denote the number of vertices of . In this work, we consider two simple, interior-disjoint curves and with and , and say that they bound a simple polygon .
A reparameterization of is a non-decreasing surjection . Two reparameterizations and of and , describe a matching between two curves and with and vertices, respectively, where any point is matched to . The matching is said to have cost
where is the geodesic distance between points in . A matching with cost at most is called a -matching. The (continuous) geodesic Fréchet distance between and is the minimum cost over all matchings. The corresponding matching is a Fréchet matching.
The parameter space of and is the axis-aligned rectangle . Any point in the parameter space corresponds to the pair of points and on the two curves. A point in the parameter space is -close for some if . The -free space of and is the set of -close points. Alt and Godau [1] observed that there is a one-to-one correspondence between -matchings between subcurves and , and bimonotone paths from to through . We abuse terminology slightly and refer to such paths as -matchings as well.
A point is -reachable from a point if and , and there exists a bimonotone (i.e., monotone in both coordinates) path in from to . That is, if the subcurves and have Fréchet distance at most between them. Points that are -reachable from are simply called -reachable points.
Let be a parameter. A -approximate decision algorithm for our problem takes a decision parameter , and outputs either that or that . It may report either answer if .
2 Algorithmic outline
In this section we sketch the major parts of our algorithm that approximates the geodesic Fréchet distance between curves and . We approximate using a -approximate decision algorithm, and use binary search to find the correct decision parameter. In Section 3.4 we relate the Fréchet distance to the geodesic Hausdorff distance , which allows us to bound the number of iterations of the binary search. In particular, we show that lies in the range . The Hausdorff distance can be computed in time [10, Theorem 7.1]. A binary search over results in a -approximation of the Fréchet distance after calls to the decision algorithm. Theorem 1 follows.
Theorem 1.
For any , we can compute a -approximation to in time.
The approximate decision algorithm.
In the remainder of this section we outline the approximate decision algorithm, which is presented in detail in Section 3. At its heart lies a useful connection between matchings and nearest neighbors. A nearest neighbor of a point on is any point on that among all points on is closest to . We denote the nearest neighbor(s) of by . We prove in Section 3.1 that any -matching matches each nearest neighbor of relatively close to . Specifically, must be matched to only points for which the entire subcurve of between and is within distance of . We introduce the concept of a -nearest neighbor fan to capture the candidate locations for .
The -nearest neighbor fan contains the point and the maximal subcurve that contains and is within geodesic distance of ; it is the union of geodesics between and points on , see Figure 2. We call the apex of and the leaf of the fan. We prove in Section 3.1 that any -matching must match the apex to a point in the leaf .
As moves forward along , so do its nearest neighbors along . Their nearest neighbor fans move monotonically through the polygon bounded by and . However, while moves continuously along , the points and their nearest neighbor fans might jump discontinuously. Such discontinuities occur due to points that are not a nearest neighbor of any point on , and thus at points that are not the apex of a nearest neighbor fan. We classify the points on accordingly: we call a point on a near point if it is a nearest neighbor of at least one point on , and call a far point otherwise.
The distinction between near and far points induces a partition of the parameter space into horizontal slabs. We consider these slabs from bottom to top, and iteratively construct a -matching (provided that one exists). Recall that a -matching is a bimonotone path in from the bottom-left corner of the parameter space to the top-right corner.
Inside a slab corresponding to a subcurve of with only near points, the nearest neighbor fans correspond to a connected, -monotone and -monotone region spanning the entire height of . These regions are illustrated in Figure 3. The intersection between any -matching and is contained in . The structure of implies that if a -matching between and exists, there exists one which moves vertically up inside whenever this is possible. Geometrically, this corresponds to greedily traversing the near points on , and traversing parts of only when necessary. We formalize this in Section 3.2.
Slabs whose corresponding subcurves of have only far points pose the greatest technical challenge for our algorithm; we show how to match far points in an approximate manner in Section 3.3. Specifically, let correspond to a subcurve with only far points on its interior. We compute a suitable subcurve of that can be -matched to in the following manner. First we argue that . In other words, the geodesic from to is short and separates from the subcurve . We use this separating geodesic to transform the problem of creating a matching for far points into one-dimensional problems.
Specifically, we discretize the separator with points, which we call anchors, and ensure that consecutive anchors are at most apart. We snap our geodesics to these anchors (see Figure 4), which incurs a small approximation error. Based on which anchor a geodesic snaps to, we partition the parameter space of and into regions, one for each anchor. For each anchor point, the lengths of the geodesics snapped to it can be expressed as distances between points on two separated one-dimensional curves; this results in a one-dimensional problem which we can solve exactly. In Section 3.3 we present the transformation into one-dimensional curves, and in Section 4 we present an efficient exact algorithm for the resulting one-dimensional problem.
3 Approximate geodesic Fréchet distance
3.1 Nearest neighbor fans and partitioning the parameter space
We first present useful properties of nearest neighbor fans and their relation to matchings. In Lemma 3 we give a crucial property of nearest neighbor fans, namely that any -matching between and matches to only points in the leaf of the fan. For the proof, we make use of the following auxiliary lemma:
Lemma 2.
Let and . For any points and on opposite sides of the geodesic between and , we have .
Lemma 3.
Let and . For any , every -matching between and matches to only points in the leaf of .
Proof.
Fix a -matching and let be a point matched to by this matching. Assume without loss of generality that comes before along . Let be a point between and . The -matching matches to at least one point after . Thus we obtain from Lemma 2 that . This proves that all points between and are included in the leaf of . We partition the parameter space into (closed) maximal horizontal slabs, such that for each slab , either the subcurve contains only near points, or its interior contains only far points. Let be the resulting partition. Each slab has two horizontal line segments, one on its bottom and one on its top side, that correspond to nearest neighbor fans. We refer to these line segments as the entrance and exit intervals of , and refer to points on them as the entrances and exits of . A consequence of Lemma 3 is that any -matching enters and leaves through an entrance and an exit, respectively. We compute -safe entrances and exits: -reachable points from which is -reachable. Each such point is used by a -matching, and is used to iteratively determine if such a matching exists.
It proves sufficient to consider only a discrete set of entrances and exits for each slab. For each slab, we identify (implicitly) a set of entrances and exits that contain -safe entrances and exits (if any exist at all). We define these entrances and exits using locally closest points and will call them transit points.
A point on is locally closest to a point on if perturbing infinitesimally while staying on increases its distance to . The transit entrances and exits are those entrances and exits where is either a vertex or locally closest to . We show that it is sufficient to consider only transit entrances and exits:
Lemma 4.
If there exists a -matching, then there exists one that enters and leaves each slab through a transit entrance and exit.
Our algorithm computes a -safe transit exit for each slab. To do so, it requires the explicit entrance and exit intervals. We compute these using a geodesic Voronoi diagram.
Lemma 5.
The partition consists of slabs. We can compute , together with the entrance and exit interval of each slab, in time in total.
3.2 Slabs of near points
Let be a slab corresponding to a subcurve of with only near points. We use properties of nearest neighbor fans to determine a -safe transit exit of . A crucial property is that the nearest neighbor fans behave monotonically with respect to their apexes, if is large enough. Specifically, this is the case if , the geodesic Hausdorff distance between and . This is the maximum distance between a point on and its closest point on the other curve.
Lemma 6.
Suppose . Let and be near points on and let and be the leaves of their respective nearest neighbor fans. If comes before , then and .
The monotonicity of the nearest neighbor fans, together with the fact that each point on corresponds to such a fan, ensures that we can determine such an exit in logarithmic time (see Lemma 8). We make use of the following data structure that reports transit exits:
Lemma 7.
Given the exit interval of , we can report the at most three transit exits on a horizontal line segment , for any integer , in time, after preprocessing time.
Lemma 8.
Suppose . Let be a slab corresponding to a subcurve of with only near points. Given the exit interval of , together with a -safe transit entrance, we can compute a -safe transit exit in time, after preprocessing time.
Proof (sketch).
Given a -safe transit entrance , the leftmost transit exit to the right of is -safe. We report it with the data structure of Lemma 7.
3.3 Slabs of far points
Next we give an algorithm for computing a -safe transit exit of a given slab that corresponds to a subcurve of with only far points on its interior. Our algorithm is approximate: given , it computes an -safe transit exit (if one exists). This is a -reachable point from which is -reachable. Such a transit exit behaves like a -safe transit exit for the purpose of iteratively constructing a matching.
To compute an -safe transit exit, we make use of an approximate decision algorithm that uses the fact that has only far points on its interior. We present this algorithm in Section 3.3.1. In Section 3.3.2 we then apply this approximate decision algorithm in a search procedure, where we search over the transit exits to compute an -safe one.
3.3.1 Approximate decision algorithm for far points
Let be the subcurve of that corresponds to , so its interior has only far points. Let be an arbitrary subcurve of , for which we seek to approximately determine whether . We report either that , or that .
For our algorithm, we first discretize the space of geodesics between points on and points on , by grouping the geodesics into few () groups and rerouting the geodesics in a group through some representative point. Let and be the first, respectively last, endpoints of . There is a point on with . We observe that this implies the geodesic that connects to is short with respect to the Fréchet distance, and thus with respect to any relevant value for :
Lemma 9.
.
We assume for the remainder that ; if this is not the case, we immediately report that . This assumption means that the geodesic is a short separator between and . That is, any geodesic between a point on and a point on intersects . For clarity, we denote by the separator . We use the short separator to formulate the (exact) reachability problem as subproblems involving one-dimensional curves. This is where we incur a small approximation error.
We discretize with points , which we call anchors, and ensure that consecutive anchors at most a distance apart, see Figure 5 (left). We assume that no anchor coincides with a vertex of (except for and ).
We route geodesics between points on and points on through these anchors. Specifically, for points and , if intersects between consecutive anchors and , then we “snap” to ; that is, we replace it by the union of and (see Figure 5 (right)). This creates a new path between and that goes through and has length at most .
We associate an anchor with the points in the parameter space for which the geodesic is snapped to . These points form a region that is connected and monotone in both coordinates (see Figure 5 (right)). We iteratively compute, for each region , a set of -reachable points on its boundary, such that the decision question can be answered by checking if the last set contains . We later formulate these subproblems in terms of pairs of one-dimensional curves that are separated by a point.
We first discretize the problem. For this, we identify sets of points on the shared boundaries between the pairs of adjacent regions, such that there exists a -matching that enters and exits each region through such a set. Specifically, for , we let the set contain those points for which one of and is a vertex or locally closest to (so perturbing the point infinitesimally along its curve increases its distance to ). We set . In the following lemmas, we show that these sets suit our needs and are efficiently constructable.
Lemma 10.
If there exists a -matching between and , then there exists one that goes through a point in for every anchor .
Lemma 11.
Each set contains points and can be constructed in time, after preprocessing time.
Having constructed the sets for all anchors in time altogether, we move to computing subsets containing all -reachable points, and only points that are -reachable. We proceed iteratively, constructing from . For this, observe that for any point in the interior of , the geodesic was snapped to . We use this fact to construct a pair of one-dimensional curves that approximately describe the lengths of these geodesics.
Let and be one-dimensional curves, where we set and (note the difference in sign). These curves encode the distances between points on and when snapping geodesics to . That is, is the length of after snapping to . Hence, for any pair of points and , we have the following relations:
-
If is -reachable from in the parameter space of and , then it is -reachable in the parameter space of and .
-
Conversely, if is -reachable from in the parameter space of and , then it is -reachable in the parameter space of and .
We define as the points in that are -reachable from points in , in the parameter space of and . Computing these points is the problem involving one-dimensional curves that we alluded to earlier.
Lemma 12.
Given , we can compute in time, after preprocessing time.
We apply the above procedure iteratively, computing for each anchor . These sets take a total of time to construct. Afterwards, if , we report that . Otherwise, we report that . We obtain:
Lemma 13.
Let be an arbitrary subcurve of , and let be a maximal subcurve of with only far points on its interior. We can decide whether or in time, after preprocessing time.
3.3.2 Computing a good exit
Recall that we set out to compute an -safe transit exit of . We assume we are given an -safe entrance . Since the entire exit interval of lies in , it suffices to compute a transit exit that is -reachable from and that lies to the left of all transit exits that are -reachable from , see Figure 6. We compute such a transit exit through a search procedure, combined with the decision algorithm.
There are transit exits of . To avoid running the decision algorithm for each of these, we use exponential search. The choice for exponential search over, e.g., binary search comes from the fact that the running time of the decision algorithm depends on the location of the transit exit, with transit exits lying further to the right in the exit interval of needing more time for the decision algorithm. Exponential search ensures that we do not consider transit exits that are much more to the right than needed.
Lemma 14.
Let be a slab corresponding to a subcurve of with only far points on its interior. Given an -safe transit entrance of , we can compute an -safe transit exit in time.
3.4 The approximate optimization algorithm
We combine the algorithms of Sections 3.2 and 3.3 to obtain a -approximate decision algorithm, which we then turn into an algorithm that computes a -approximation of the geodesic Fréchet distance between and . Given and , the approximate decision algorithm reports that or .
Let be the geodesic Hausdorff distance between and . This distance, which is the maximum distance between a point on to its closest point on the other curve, is a natural lower bound on the geodesic Fréchet distance. If , we therefore immediately return that . We can compute in time [10].
Next suppose . For our approximate decision algorithm, we first compute the partition and the entrance and exit intervals of each of its slabs. By Lemma 5, this takes time. We iterate over the slabs of from bottom to top. Once we consider a slab , we have computed an -safe transit entrance (except if is the bottom slab, in which case we set ).
Let be the subcurve corresponding to . If contains only near points, we compute a -safe transit exit of in time with the algorithm of Section 3.2. Otherwise, we use the algorithm of Section 3.3, which takes time. Both algorithms require preprocessing time. Taken over all slabs in , the total complexity of the subcurves is . This gives the following result:
Theorem 15.
For any , there is a -approximate decision algorithm running in time.
We turn the decision algorithm into an approximate optimization algorithm with a simple binary search. For this, we show that the geodesic Fréchet distance is not much greater than . This gives an accurate “guess” of the actual geodesic Fréchet distance.
Lemma 16.
.
For our approximate optimization algorithm, we perform binary search over the values and run our approximate decision algorithm with each encountered parameter. This procedure yields a -approximation to the geodesic Fréchet distance. Since for , scaling by a factor of gives our main result:
Theorem 1. [Restated, see original statement.]
For any , we can compute a -approximation to in time.
4 Separated one-dimensional curves and propagating reachability
In this section we consider the following problem: Let and be two one-dimensional curves with and vertices, respectively, where lies left of the point and right of it. We are given a set of “entrances,” for some . Also, we are given a set of “potential exits.” We wish to compute the subset of potential exits that are -reachable from an entrance. We call this procedure propagating reachability information from to . We assume that the points in and correspond to pairs of vertices of and . This assumption can be met by introducing vertices, which does not increase our asymptotic running times. Additionally, we may assume that all vertices of and have unique values, for example by a symbolic perturbation.
The problem of propagating reachability information has already been studied by Bringmann and Künnemann [4]. In case lies on the left and bottom sides of the parameter space and lies on the top and right sides, they give an time algorithm. We are interested in a more general case however, where and may lie anywhere in the parameter space. We make heavy use of the concept of prefix-minima to develop an algorithm for our more general setting that has the same running time as the one described by Bringmann and Künnemann [4]. Furthermore, our algorithm is able to actually compute a Fréchet matching between and in linear time (see the full version of this paper), whereas Bringmann and Künnemann require near-linear time for only the decision version.
As mentioned above, we use prefix-minima extensively for our results in this section. Prefix-minima are those vertices that are closest to the separator among those points before them on the curves. In the full version of this paper, we prove that a Fréchet matching exists that matches subcurves between consecutive prefix-minima to prefix-minima of the other curve, see Figure 7 for an illustration. We call these matchings prefix-minima matchings. This matching will end in a bichromatic closest pair of points, and so we can compose the matching with a symmetric matching for the reversed curves.
In Section 4.1 we introduce two geometric forests in , with leaves at , that capture multiple prefix-minima matchings at once. It is based on horizontal-greedy and vertical-greedy matchings. We show that these forests have linear complexity and can be computed efficiently.
In Section 4.2 we do not only go forward from points in , but also backwards from points in using suffix-minima. Again we have horizontal-greedy and vertical-greedy versions. Intersections between the two prefix-minima forests and the two suffix minima forests show the existence of a -free path of the corresponding points in and , so the problem reduces to a bichromatic intersection algorithm.
4.1 Greedy paths in the free space
We wish to construct a set of canonical prefix-minima -matchings in the free space from which we can deduce which points in are reachable. Naturally, we want to avoid constructing a path between every point in and every point in . Therefore, we investigate certain classes of prefix-minima -matchings that allows us to infer reachability information with just two paths per point in and two paths per point in . Furthermore, these paths have a combined description complexity.
We first introduce one of the greedy matchings and prove a useful property. A horizontal-greedy -matching is a prefix-minima -matching starting at a point that satisfies the following property: Let be a point on where and are prefix-minima of and . If there exists a prefix-minimum of after , and the horizontal line segment lies in , then either traverses this line segment, or terminates in .
For an entrance , let be the maximal horizontal-greedy -matching. See Figure 8 for an illustration. The path serves as a canonical prefix-minima -matching, in the sense that any point that is reachable from by a prefix-minima -matching is reachable from a point on through a single vertical segment:
Lemma 17.
Let and let be a point that is reachable by a prefix-minima -matching from . A point vertically below exists for which the segment lies in .
A single path may have complexity. We would like to construct the paths for all entrances, but this would result in a combined complexity of . However, due to the definition of the paths, if two paths and have a point in common, then the paths are identical from onwards. Thus, rather than explicitly describing the paths, we instead describe their union. Specifically, the set forms a geometric forest whose leaves are the points in , see Figure 8. This forest has low complexity and can be constructed efficiently:
Lemma 18.
The forest has vertices.
Lemma 19.
We can construct a geometric graph for in time.
4.2 Propagating reachability
Next we give an algorithm for propagating reachability information. For the algorithm, we consider three more -matchings that are symmetric in definition to the horizontal-greedy -matchings. The first is the maximal vertical-greedy -matching , which, as the name suggests, is the maximal prefix-minima -matching starting at an entrance that prioritizes vertical movement over horizontal movement. The other two require a symmetric definition to prefix-minima, namely suffix-minima. These are the vertices closest to compared to the suffix of the curve after the vertex. The maximal reverse horizontal- and vertical-greedy -matchings and , starting at a potential exit , are symmetric in definition to the maximal horizontal- and vertical-greedy -matching, except that they move backwards, to the left and down, and their vertices correspond to suffix-minima of the curves (see Figure 9).
Consider a point and let be -reachable from . Let and form a bichromatic closest pair of and . Note that these points are unique, by our general position assumption. We prove in the full version of this paper that is -reachable from , and that is -reachable from .
From Lemma 17 we have that has points vertically below , and the vertical segment between and lies in . We extend the property to somewhat predict the movement of near :
Lemma 20.
Either terminates in , or it contains a point vertically below or horizontally left of .
Based on Lemmas 17 and 20 and their symmetric counterparts, and satisfy the properties below, and and satisfy symmetric properties, see Figure 10.
-
has a point vertically below , and the vertical segment between and lies in .
-
has a point horizontally left of , and the horizontal segment between and lies in .
-
and both either terminate in , or contain a point vertically below or horizontally left of .
These properties mean that either intersects , or the following extensions do: Let be the path obtained by extending with the maximum horizontal line segment in whose left endpoint is the end of . Define symmetrically, by extending with a vertical segment. Also define and analogously. By Lemma 17, or must intersect or . Furthermore, if or intersects or for some potential exit , then the bimonotonicity of the paths implies that is -reachable from . Thus:
Lemma 21.
A point is -reachable from a point if and only if intersects .
Recall that represents all paths . We augment to represent all paths . For this, we take each root vertex and compute the maximal horizontal segment that has as its left endpoint. We compute this segment in time after time preprocessing (for details, refer to the full version of this paper). We then add as a vertex to , and add an edge from to .
Let be the augmented graph. We define the graphs , and analogously. The four graphs have a combined complexity of and can be constructed in time. Our algorithm computes the edges of and that intersect an edge of or . We do so with a standard sweepline algorithm:
Lemma 22.
Given sets of “red” and “blue,” axis-aligned line segments in , we can report all segments that intersect a segment of the other color in time.
Suppose we have computed the set of edges of and that intersect an edge of or . We store in a red-black tree, so that we can efficiently retrieve and remove edges from this set. Let and suppose is an edge of . Let be the top-right vertex of . All potential exits of that are stored in the subtree of are reachable from a point in . We traverse the entire subtree of , deleting every edge we find from . Every point in we find is marked as reachable. In this manner, we obtain:
Theorem 23.
Let and be two separated one-dimensional curves with and vertices. Let , and let be sets of points. We can compute the set of all points in that are -reachable from points in in time.
5 Conclusion
We studied computing the approximate geodesic Fréchet distance of two curves and that bound a simple polygon , one clockwise and one counterclockwise, whose endpoints meet. Our algorithm is approximate, though the only approximate parts are for matching the far points and turning the decision algorithm into an optimization algorithm. Doing so exactly and in strongly subquadratic time remains an interesting open problem.
Our algorithm extends to the case where and do not cover the complete boundary of the polygon. In other words, the start and endpoints of and need not coincide. Geodesics between points on and must stay inside . In this case, can be much greater than , which influences the preprocessing and query times of various data structures we use. The running time then becomes: .
References
- [1] Helmut Alt and Michael Godau. Computing the Fréchet distance between two polygonal curves. International Journal of Computational Geometry & Applications, 5:75–91, 1995. doi:10.1142/S0218195995000064.
- [2] Lotte Blank and Anne Driemel. A faster algorithm for the Fréchet distance in 1D for the imbalanced case. In Proc. 32nd Annual European Symposium on Algorithms (ESA), volume 308 of LIPIcs, pages 28:1–28:15, 2024. doi:10.4230/LIPICS.ESA.2024.28.
- [3] Karl Bringmann. Why walking the dog takes time: Fréchet distance has no strongly subquadratic algorithms unless SETH fails. In Proc. 55th Annual Symposium on Foundations of Computer Science (FOCS), pages 661–670, 2014. doi:10.1109/FOCS.2014.76.
- [4] Karl Bringmann and Marvin Künnemann. Improved approximation for Fréchet distance on c-packed curves matching conditional lower bounds. International Journal of Computational Geometry & Applications, 27(1-2):85–120, 2017. doi:10.1142/S0218195917600056.
- [5] Kevin Buchin, Maike Buchin, Wouter Meulemans, and Wolfgang Mulzer. Four soviets walk the dog: Improved bounds for computing the Fréchet distance. Discrete & Computational Geometry, 58(1):180–216, 2017. doi:10.1007/s00454-017-9878-7.
- [6] 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 Proc. 30th Annual Symposium on Discrete Algorithms (SODA), pages 2887–2901, 2019. doi:10.1137/1.9781611975482.179.
- [7] Erin W. Chambers, Éric Colin de Verdière, Jeff Erickson, Sylvain Lazard, Francis Lazarus, and Shripad Thite. Homotopic Fréchet distance between curves or, walking your dog in the woods in polynomial time. Computational Geometry, 43(3):295–311, 2010. doi:10.1016/J.COMGEO.2009.02.008.
- [8] Siu-Wing Cheng, Haoqiang Huang, and Shuo Zhang. Constant approximation of Fréchet distance in strongly subquadratic time. CoRR, abs/2503.12746, 2025. doi:10.48550/arXiv.2503.12746.
- [9] Connor Colombe and Kyle Fox. Approximating the (continuous) Fréchet distance. In Proc. 37th International Symposium on Computational Geometry (SoCG), pages 26:1–26:14, 2021. doi:10.4230/LIPIcs.SoCG.2021.26.
- [10] Atlas F. Cook IV and Carola Wenk. Geodesic Fréchet distance inside a simple polygon. ACM Transactions on Algorithms, 7(1):9:1–9:19, 2010. doi:10.1145/1868237.1868247.
- [11] Anne Driemel, Sariel Har-Peled, and Carola Wenk. Approximating the Fréchet distance for realistic curves in near linear time. Discrete & Computational Geometry, 48(1):94–127, 2012. doi:10.1007/s00454-012-9402-z.
- [12] Alon Efrat, Leonidas J. Guibas, Sariel Har-Peled, Joseph S. B. Mitchell, and T. M. Murali. New similarity measures between polylines with applications to morphing and polygon sweeping. Discrete & Computational Geometry, 28(4):535–569, 2002. doi:10.1007/S00454-002-2886-1.
- [13] Sariel Har-Peled, Amir Nayyeri, Mohammad R. Salavatipour, and Anastasios Sidiropoulos. How to walk your dog in the mountains with no magic leash. Discrete & Computational Geometry, 55(1):39–73, 2016. doi:10.1007/S00454-015-9737-3.
- [14] Thijs van der Horst, Marc van Kreveld, Tim Ophelders, and Bettina Speckmann. A near-linear time exact algorithm for the -geodesic Fréchet distance between two curves on the boundary of a simple polygon. To appear at the Algorithms and Data Structures Symposium (WADS), 2025.
- [15] Thijs van der Horst, Marc J. van Kreveld, Tim Ophelders, and Bettina Speckmann. A subquadratic n-approximation for the continuous Fréchet distance. In Proc. ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1759–1776, 2023. doi:10.1137/1.9781611977554.ch67.
