Adaptive Computation of the Discrete Fréchet Distance
aa r X i v : . [ c s . C G ] J un Adaptive Computation of theDiscrete Fréchet Distance
Jérémy Barbay
Departamento de Ciencias de la Computación,University of Chile, [email protected]
Abstract.
The discrete Fréchet distance is a measure of similarity between point sequences whichpermits to abstract differences of resolution between the two curves, approximating the original Fréchetdistance between curves. Such distance between sequences of respective length n and m can be computedin time within O ( nm ) and space within O ( n + m ) using classical dynamic programing techniques, acomplexity likely to be optimal in the worst case over sequences of similar lenght unless the StrongExponential Hypothesis is proved incorrect. We propose a parameterized analysis of the computationalcomplexity of the discrete Fréchet distance in fonction of the area of the dynamic program matrixrelevant to the computation, measured by its certificate width ω . We prove that the discrete Fréchetdistance can be computed in time within (( n + m ) ω ) and space within O ( n + m + ω ) . Measuring the similarity between two curves has applications in areas such as handwriting recognition [14],protein structure alignment [10], quantifying macro-molecular pathways [13], morphing [3], movement anal-ysis [7], and many others [15]. One of the most popular solutions, the
Fréchet Distance is a measure ofsimilarity between two curves P and Q , that takes into account the location and ordering of the points alongthe curves. It permits, among other features, to abstract the difference of resolution between P and Q , withapplication to morphing, handwriting recognition and protein structure alignment, among others [15]. In1995, Art and Godau [9] described an algorithm computing the Fréchet Distance between two polygonalcurves composed of n and m segments respectively in time within O ( mn log( mn )) .One year before (1994), Eiter and Mannila [4] had extended the notion of the Fréchet Distance between curves to the
Discrete Fréchet Distance between sequence of points of respective sizes n and m , demonstrating that the latter can be used to approximate the former in time within O ( nm ) and spacewithin O ( n + m ) using classical dynamic programming techniques. Two decades later (2014), Bringmann [2]showed that this worst case complexity is likely to be optimal, unless a bunch of other problems (amongwhich CNF SAT) can be computed faster than usually expected. Hence, the bounds about the computationalcomplexity of the Discrete Fréchet Distance in the worst case over instances of input sizes n and m are reasonably tight.Yet, for various restricted classes of curves (e.g. κ -bounded, backbone, c -packed and long-edged [8] curves),both the Fréchet Distance and the
Discrete Fréchet Distance are known to be easier to compute.Among other examples, we consider the
Fréchet Distance Decision problem , which consists in decidingwhether the
Fréchet Distance between two curves is equal to a given value f . In 2018, Gudmundssonet al. [8] described an algorithm deciding if the Fréchet Distance is equal to a given value f in timelinear in the size of the input curves when each edge is longer than the Fréchet Distance between thosetwo curves. Based on this algorithm, they also showed how to approximate the
Fréchet Distance withina factor of √ d in linear time, and preprocessed in linear time in order to support decision queries in timewithin O ( m log n ) . Those results easily project to the Discrete Fréchet Distance .Those results for the mere computation of the
Discrete Fréchet Distance suggest that one does notalways need to compute the n × m values of the dynamic program. Can such approaches be applied tomore general instances , such that the area of the dynamic program which needs to be computed measures the difficulty of the instance ?n this work we perform a parameterized analysis of the computational complexity of the
DiscreteFréchet Distance , in function of the area of the dynamic program matrix relevant to the computation,measured by its certificate width ω . After describing summarily the traditional way to compute the DiscreteFréchet Distance and the particular case of long edged curves (Section 2), we describe an optimization ofthe classical dynamic program based on two simple techniques, banded dynamic programming and threshold-ing (Section 3), and we prove that this program runs in time within O (( n + m ) ω ) and space within O ( n + m ) (Section 4). We conclude with a discussion in Section 5 of how our results generalize those of Gudmunds-son et al. [8], and the potential applications and generalizations of our techniques to other problems wheredynamic programs have given good results Before describing our results, we describe some classical results upon which we build: the classical dynamicprogram computing the
Discrete Fréchet Distance , and the “easy” case of long-edged curves describedby Gudmundsson et al. [8].
Classical Dynamic Program
Let P [1 ..n ] and Q [1 ..m ] be sequences of n and m points with n ≥ m . The Discrete Fréchet Distance between P and Q is the minimal width of a traversal of P and Q , where thewidth of a traversal is the maximal distance separating two points u ∈ P and v ∈ Q , where u and v progressindependently, but always forward.Such a distance is easily computed using classical techniques from dynamic programming. The distancebetween P [1 ..n ] and Q [1 ..m ] can be reduced in constant time to the minimum between the distance between P [1 ..n − and Q [1 ..m ] , the distance between P [1 ..n ] and Q [1 ..m − , and the distance between P [1 ..n − and Q [1 ..m − . Algorithm 1 (page 3) describes a simple implementation in Python , executing in time within O ( nm ) . While such a simple algorithm also requires space within O ( nm ) , a simple optimization yields a spacewithin O ( n + m ) , by computing the Discrete Fréchet Distance between P [1 ..i ] and Q [1 ..j ] for increasingvalues of i and j , one column and row at the time, keeping in memory only the previous column and row.We describe in Section 3 a more sophisticated algorithm which avoids computing some of the n × m valuescomputed by Algorithm 1. Easy instances of the Fréchet Distance
For various restricted classes of curves, such as κ -bounded,backbone, c -packed and long-edged [8] curves, both the Fréchet Distance and the
Discrete FréchetDistance are known to be easier to compute (or approximate).A curve P is κ -bounded if for any two points x, y ∈ P , the union of the balls with radii r centered at yand y contains the whole P [ x, y ] where r is equal to ( κ/ times the Euclidean distance between x and y .Alt et al. described an algorithm to approximate within a factor of κ the Discrete Fréchet Distance between two such curves of length at most n , in time within O ( n lg n ) .A backbone curve has constant edge length and requires a minimum distance between non-consecutivevertices. Aronov et al. described an algorithm approximating within a factor of (1 + ε ) the DiscreteFréchet Distance of such curves in time near-linear in the size of the curves.A curve P is c -packed if for any ball B the length of the portion of P contained in B is at most c timesthe diameter of B .In 2018, Gudmundsson et al. [8] showed that in the special case where all the edges of the polygonalcurve are longer than the Fréchet Distance , the latter can be decided (i.e., checking a value of the
Fréchet Distance ) in linear time in the size of the input, computed in time within O (( n + m ) lg( n + m )) ,approximated within a factor of √ d in linear time in the size of the input, and preprocessed in linear timein order to support decision queries in time within O ( m log n ) .In the next section, we describe a quite simple algorithm which not only takes advantage of long edgedcurves, but of any pair of curves for which a consequent part of the array of the dynamic program can beignored. 2 lgorithm 1 Classical algorithm to compute the
Discrete Fréchet Distance between two sequencesof points P and Q . The implementation is decomposed in two parts: the computation function initial-izes the array of values, which is filled recursively by the recursive function. For the sake of space, thedocumentation strings and unit tests were not included, but the source file including those is available at https://github.com/FineGrainedAnalysis/Frechet . def recursive (dpA ,i ,j ,P ,Q ): if dpA [i ,j] > − return dpA [i ,j] elif i == 0 and j == 0:dpA [i ,j] = distance (P [0] , Q [0]) elif i > 0 and j == 0:dpA [i ,j] = max (recursive ( dpA ,i − elif i == 0 and j > 0:dpA [i ,j] = max (recursive ( dpA ,0 ,j − elif i > 0 and j > 0:dpA [i ,j] = max ( min ( recursive ( dpA ,i − − − − else :dpA [i ,j] = float (" inf ") return dpA [i ,j] def computation (P ,Q ):dpA = numpy . ones (( len (P), len (Q )))dpA = numpy . multiply ( dpA , − len (P) − len (Q) − return d An opportunistic Dynamic Program
We describe an algorithm based on two complementary techniques: first, a banded dynamic program , which approximates the value computed by a classical dynamic program by considering only the values of thedynamic program within a range of width w (for some parameter w ) around the diagonal (a techniquepreviously introduced for the computation of the Edit Distance between two strings); and second, a thresholding process, which accelerates the computation by cutting the recurrence any time the distancecomputed becomes larger or equal to a threshold t (for some parameter t corresponding to a distance alreadyachieved by some traversal of the two curves). The combination of those two techniques, combined with aparametrization of the problem, yields the parameterized upper bound on the computational complexity ofthe Discrete Fréchet Distance . Banded Dynamic Program:
When computing the
Edit Distance (e.g., the
Delete Insert EditDistance , or the
Levenshtein Edit Distance [1]) between similar strings S ∈ [1 ..σ ] n and T ∈ [1 ..σ ] m (i.e., their Edit Distance d is small), it is possible to compute less than n × m cells of the dynamic programarray, and hence compute the Edit Distance in time within O ( d ( n + m )) ⊆ O ( nm ) . The “trick” is basedon the following observation: when the distance between the two strings is d , the “paths” corresponding to d operations transforming S into T in the matrix of the dynamic program errs at most at distance d fromthe diagonal between the cell (1 , and the cell ( n, m ) . Based on this observation, it is sufficient to computethe number of operations corresponding to paths inside a “band” of width d around such a diagonal [1]. Thistechnique needs some adaptation to be applied to the computation of the Discrete Fréchet Distance f between two curves, for two reasons: first, f is a real number (it corresponds to the Euclidean distancebetween two points) and not an integer as the number of edition operations, and this number is independentof the number of cells of the dynamic program being computed; and second, the definition of the DiscreteFréchet Distance is based on a maximum rather than a sum, which actually makes another optimizationpossible, described in the next paragraph.
Thresholding:
Given two sequences of points P [1 ..n ] and Q [1 ..m ] , consider the Euclidean matrix E ( P, Q ) of all n × m distances between a point u ∈ P and a point v ∈ Q . Any parallel traversal of P and Q correspondsto a path in E ( P, Q ) from the top left cell (1 , to the bottom right cell ( n, m ) ; the width of such a traversalis the maximum value in E ( P, Q ) on this path; and the Discrete Fréchet Distance is the minimumwidth achieved over all such traversals.Now suppose that, as for the
Edit Distance between two similar strings, the traversal of the Euclideanmatrix E ( P, Q ) corresponding to the Discrete Fréchet Distance f between P and Q is close to thediagonal from (1 , to ( n, m ) , and that any traversal diverging from such a path “encounters” a pair of points ( u, v ) at euclidean distance larger than f (in particular, this happens when the two curves are “long edged”compared to f ). Then, some of the values of the cells of the dynamic program matrix outside of this diagonalcan be ignored for the computation of the Discrete Fréchet Distance between P and Q .In the following paragraph we describe how to combine those two techniques into an adaptive algorithmtaking advantage of “easy” instances where a large quantity of cells of the dynamic program can be ignored. Combining the two techniques:
The solution described consists of two algorithms: an approximationalgorithm 2 which computes a parameterized upper bound on the
Discrete Fréchet Distance , and acomputation algorithm 3 which calls the previous one iteratively with various parameter values, in order tocompute the real
Discrete Fréchet Distance of the instance.Algorithm 2 lists an implementation in
Python of an algorithm which, given as parameters two arrays ofpoints P and Q , an integer width w , and a float threshold t ; computes an upper bound of the DiscreteFréchet Distance between P and Q , obtained by computing only the cells within a band of width w around the diagonal from the top left cell (1 , to the bottom right cell ( n, m ) , and cutting all sequences ofrecursive calls when reaching a distance of value t or above. This algorithm uses space within ( n + m ) as it4omputes the values from (1 , to ( n, m ) by updating and switching alternatively two arrays of size n andtwo arrays of size m (respectively corresponding to rows and columns of the dynamic program matrix). Itsrunning time is within O ( w ( n + m )) , as it computes at most w ( n + m ) cells of the dynamic program array.Furthermore, it not only returns the value of the upper bound computed, but also a Boolean breached indicating if the border of the banded diagonal has been reached during this computation. When such aborder has not been reached (and the threshold value t is smaller than or equal to the Discrete FréchetDistance between P and Q ), the value returned is equal to the Discrete Fréchet Distance between P and Q .Algorithm 3 lists an implementation in Python of an algorithm which, given as parameters two sequencesof points P and Q , calls the approximation Algorithm 2 on P and Q for widths of exponentially increasingvalue (by a factor of two). The first call is performed with an infinite threshold (no information is availableon the similarity of the curve at this point), but each successive calls use the best upper bound on the Discrete Fréchet Distance between P and Q previously computed as a threshold.The intuition of the correctness of Algorithm 3 is trivial: on the last execution of Algorithm 2, either allthe values of the dynamic program array were computed, or all recursions where stopped before they reacheda value which is not computed (because out of the bandwidth). We formalize the argument in the followingtheorem. Theorem 1.
Algorithm 3 correctly returns the
Fréchet Distance of the two input sequences of points.Proof.
Consider two sequences of points P and Q given as input to Algorithm 3. On the last execution ofAlgorithm 2, – the threshold value corresponds to a viable traversal of the Fréchet matrix, and – either all the values of the dynamic program array were computed ( w = n ), or all recursions wherestopped before they reached a value which is not computed ( bReached = False )).As a consequence, the computation of the band of width w correctly simulates the computation of the wholedynamic program, from which the correctness of the algorithm ensues.In the next section, we analyze the running time of Algorithm 3, and describe a parameterized upper boundon it. The running time of the approximation Algorithm 2 when given parameter w is clearly within O ( w ( n + m )) :it computes within O ( w ) cells in at most n + m rounds, each in constant time. A finer upper bound taking intoaccount the value of the parameter t requires more hypothesis on the relation between P and Q , for which weneed to consider the running time of the computation Algorithm 3. We model such hypothesis on the instancein the form of a certificate , and more specifically in the form of a certificate area of the Euclidean matrixcorresponding to a set of values which suffice to certify the value of the Discrete Fréchet Distance . Definition 1.
Given two sequences of points P [1 ..n ] and Q [1 ..m ] of respective lengths n and m and of Discrete Fréchet Distance f , a Certificate Area of the instance formed by P and Q is an area of theEuclidean matrix of P and Q containing both (1 , and ( n, m ) , and delimited by two paths (one above andone below), both such that the minimum value on this path is larger than or equal to f . The width of such acertificate area is the minimal width of a banded diagonal containing both paths. The surface of such an area is a good measure of the difficulty to certify the
Discrete FréchetDistance , but the minimal width of such an area lends itself better to an analysis of the running time ofthe computation Algorithm 3:
Definition 2.
Given two sequences of points P [1 ..n ] and Q [1 ..m ] , the Certificate Width ω of ( P, Q ) is theminimum width of a certificate area, taken over all possible certificate areas of ( P, Q ) . lgorithm 2 Parameterized Algorithm to approximate the
Discrete Fréchet Distance between twosequences of points by computing only values of the dynamic program within a band of width w around thediagonal, and limiting the recursion to distances smaller than a threshold t . def approximation (P ,Q ,w ,t ):bReached = Falsen = len (P)m = len (Q)assert ( m <= n )assert ( m > 0 ) def e(i ,j ):d = utils . distance (P[i], Q[j ]) if d < t: if (i − j) >= w or (j − i) >= w:bReached = True return d else : return float (" inf ")oldRow = np . ones (n)oldColumn = np . ones (m)oldRow [0] = oldColumn [0] = e (0 ,0) for s in range (1 , m ):newRow = np . ones (n) for i in range ( max (1 , s − w +1) , s ):newRow [i] = max (e(i ,s), min (oldRow [i],oldRow [i − − for j in range ( max (1 , s − w +1) , s ):newColumn [j] = max (e(s ,j), min (newColumn [j − − max (e(s ,s), min (newRow [s − − − for s in range (m ,n ):newColumn = np . ones (m) for j in range ( max (1 ,s − w +1) , m ):newColumn [j] = max (e(s ,j), min (oldColumn [j],oldColumn [j − − return bReached , newRow [n − lgorithm 3 Adaptive algorithm to compute the
Discrete Fréchet Distance between two sequences ofpoints, by iteratively approximating it with increasing width, using the value of the previous approximationto potentially reduce the number of distances being computed. def computation (P ,Q ): if len (P)< len (Q ):P ,Q = Q ,P if len (Q) == 0: return float (" inf ")w = 1bReached ,t= approximation (P ,Q ,w , float (" inf " )) while bReached and w < len (Q ):w = 2 ∗ xbReached ,t= approximation (P ,Q ,w ,t) return t Such a width can be as large as n + m in the worst case over instances formed by sequences of points ofrespective lengths n and m , but the smaller this certificate width is , the faster Algorithm 3 runs: Theorem 2.
Given two sequences of points P [1 ..n ] and Q [1 ..m ] forming an instance of certificate width ω ,Algorithm 3 computes the Discrete Fréchet Distance between P and Q in time within O (( n + m ) ω ) andspace within O ( n + m ) . Beyond the necessity to measure experimentally the certificate width of practical instances of the
Dis-crete Fréchet Distance , and the exact running time of Algorithm 3 on such instances, we discuss somemore subtle options for future work in the next section.
The results described in this work are by far only preliminary. Among the various questions that thosepreliminary results raise, we discuss here the relation to the long edged sequences recently described by Gud-mundsson et al. [8]; a potential parameterized conditional lower bound matching our parameterized upperbound on the computational complexity of the
Discrete Fréchet Distance ; (the not so) similar resultson the
Orthogonal Vector decision problem; and the possibility of a theory of reductions between pa-rameterized versions of polynomial problems without clear (parameterized or not) computational complexitylower bounds.
Relation to Long Edged Sequences:
In 2018, Gudmundsson et al. [8] described an algorithm decidingif the Fréchet distance is equal to a given value f in time linear in the size of the input curves when eachedge is longer than the Fréchet Distance between those two curves. Algorithm 3 is more general thanGudmundsson et al.’s algorithm [8], but it also performs in linear time on long-edged instances: the traversalcorresponding to the
Fréchet Distance of such an instance is along the diagonal, implying a certificatewidth of . See Figures 1, 2 and 3 for the Euclidean matrix, Fréchet Matrix and Dynamic Program Matrixof a random instance formed of points, each edge of length with a Fréchet Distance of . (seeAppendix A.2 for the Python code used to generate long edged instances).The ratio between the
Fréchet Distance and the minimal edge length of the curves might prove to bea more “natural” parameter than the certificate width to measure the “difficulty” of computing the
FrŕechetDistance of a pair of curves: we focused on the certificate width in the hope that such a technique can findapplications in the analysis of other problems on which dynamic programming has yield good solutions.7 . .
43 193 .
97 294 .
66 199 .
17 227 . . . .
67 195 .
37 99 . . .
48 97 . . .
43 6 .
13 113 . .
44 192 .
56 104 . . .
26 109 . .
23 93 .
14 13 .
17 104 . . . .
69 156 .
27 112 .
89 104 .
58 107 . . Fig. 1.
Euclidean Matrix for a Long Edged Instance:the points from the first curve were randomly gen-erated at distance of each other, while the pointsfrom the second curve were generated by perturbingwithin a distance of from the points of the firstcurve. . .
43 193 .
97 294 .
66 294 .
66 294 . . . .
67 195 .
37 195 .
37 195 . .
48 97 . . .
43 105 .
43 113 . .
44 192 .
56 104 . . .
26 109 . .
44 192 .
56 104 .
04 104 . . . .
44 192 .
56 112 .
89 104 .
58 107 . . Fig. 2.
Fréchet Matrix for the same Long Edged In-stance as Figure 1: the traversal corresponding tothe
Fréchet Distance of the instance is along thediagonal (highlighted in bold here), resulting in a
Fréchet Distance of . . . inf inf − . − . − . inf . inf inf − . − . inf inf . inf . − . − . inf inf . inf inf − . − . . inf . inf − . − . − . inf inf . Fig. 3.
Dynamic Program Matrix for the same LongEdged Instance as Figure 1, with width and thresh-old : “inf” denotes interrupted recurrences becausethe distance found is already larger than the thresh-old, meanwhile values outside of the band of width are marked with “-1”. . .
48 19 . − . − . − . . . .
31 16 . − . − . .
81 14 . . . inf − . − . inf . . . . − . − . inf . . . − . − . − . .
17 14 . . Fig. 4.
Dynamic Program Matrix for a general in-stance. The points from the first curve were ran-domly generated at distance of each other, thepoints from the second curve by perturbing within adistance of the points of the first curve. The com-putation of the matrix is performed with width andthreshold as before. Parameterized Conditional Lower Bound
The original motivation for this work was to prove a param-eterized conditional lower bound on the computational complexity of the
Discrete Fréchet Distance as a step-stone for doing the same for the computation of various
Edit Distances . The first step in thisdirection was the identification of a parameter for this problem: the certificate width , that seems to be a goodcandidate. The next step is to refine the reduction from
CNF SAT to the
Discrete Fréchet Distance described by Bringmann [2], in order to define a reduction from (a potential parameterized version of)
CNFSAT to a parameterized version of the
Discrete Fréchet Distance . Parameterized Upper and Lower Bound for the computation of Orthogonal Vectors:
Bring-mann [2] mentions that the reduction from
SAT CNF to the computation of the
Discrete Fréchet Dis-tance is similar to Williams’ reduction from
SAT CNF to the (polynomial) problem of deciding if two setsof vectors contain an
Orthogonal Vector pair, and that there might be a reduction from the
Orthog-onal Vector decision problem to the computation of the
Discrete Fréchet Distance . This mentioncalled the
Orthogonal Vector decision problem to our attention, and in particular 1) the possibility ofa parametrization of the analysis of this problem, and 2) a potential linear (or parameterized) reductionfrom such a parameterized
Orthogonal Vector decision problem to the parameterized computation ofthe
Discrete Fréchet Distance described in this work. It turns out that there exists an algorithm solv-ing the
Orthogonal Vector decision problem in time within O (( n + m )( δ + log( n ) + log( m ))) , where n and m are the respective sizes of the sets of vectors forming the instance, and δ is the certificate density measuring the proportion of cells from the the dynamic program which are sufficient to compute in order tocertify the answer to the program. The reduction of this to the Discrete Fréchet Distance will be moreproblematic: the two measures of difficulty seem completely unrelated.8 theory of reduction between polynomial parameterized problems
The study of the parameter-ized complexity of NP-hard problems [6,11] yields a theory of reduction between pairs formed by a decisionproblem P and a parameter k . The study of adaptive sorting algorithms [5,12] yields a theory of reductionsbetween parameters measuring the existing disorder in an array to be sorted (which can also be seen as atheory of reductions between pairs of problems and parameters, but where all the problems are equal). Con-sidering the theory of reductions between polynomial problems such as the Discrete Fréchet Distance ,the various
Edit Distances between strings, the
Orthogonal Vector decision problem, and many oth-ers, one can imagine that it would be possible to define a theory of reductions between parameterized versionsof these problems.
Acknowledgements:
The author would like to thank Travis Gagie for interesting discussions andfor pointing out Gudmundsson et al.’s work [8].
Funding:
Jérémy Barbay is partially funded by theproject Fondecyt Regular no. 1170366 from Conicyt.
Data and Material Availability:
The source ofthis article, along with the unabridged code will be made publicly available upon publication at the url https://github.com/FineGrainedAnalysis/Frechet . References
1. Bergroth, L., Hakonen, H., Raita, T.: A survey of longest common subsequence algorithms. In: Proceedings ofthe 11th Symposium on String Processing and Information Retrieval (SPIRE). pp. 39–48 (2000)2. Bringmann, K.: Why walking the dog takes time: Fréchet distance has no strongly subquadratic algorithms unlessSETH fails. In: Proceedings of the 2014 IEEE 55th Annual Symposium on Foundations of Computer Science. pp.661–670. FOCS ’14, IEEE Computer Society, Washington, DC, USA (2014)3. Efrat, A., Guibas, L., Har-Peled, S., Mitchell, J., Murali, T.: New similarity measures between polylines withapplications to morphing and polygon sweeping. Discrete and Computational Geometry (4), 535–569 (2002)4. Eiter, T., Mannila, H.: Computing discrete Fréchet distance. Tech. rep., Christian Doppler Labor für Experten-syteme, Technische Universität Wien (1994)5. Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Computing Surveys (ACMCS) (4), 441–476 (1992)6. Flum, J., Grohe, M.: Parameterized Complexity Theory (Texts in Theoretical Computer Science. An EATCSSeries). Springer-Verlag New York, Inc., Secaucus, NJ, USA (2006)7. Gudmundsson, J., Laube, P., Wolle, T.: Movement Patterns in Spatio-Temporal Data, pp. 1362–1370. SpringerInternational Publishing, Cham (2017)8. Gudmundsson, J., Mirzanezhad, M., Mohades, A., Wenk, C.: Fast Fréchet distance between curves with longedges. In: Proceedings of the International Workshop on Interactive and Spatial Computing (WISC). pp. 52–58.IWISC ’18, ACM, New York, NY, USA (2018), best Paper Award IWISC’189. H., A., M., G.: Computing the Fréchet distance between two polygonal curves. International Journal of Compu-tational Geometry and Applications (IJCGA) (1–2), 75–91 (1995)10. Jiang M1, Xu Y, Z.B.: Protein structure-structure alignment with discrete Fréchet distance. J Bioinform ComputBiol. (1), 51–64 (2008)11. Marx, D.: Parameterized complexity of constraint satisfaction problems. In: Proceedings of 19th Annual IEEEConference on Computational Complexity (CCC). pp. 139–149 (2004)12. Moffat, A., Petersson, O.: An overview of adaptive sorting. Australian Computer Journal (ACJ) (2), 70–77(1992)13. Seyler, S.L., Kumar, A., Thorpe, M.F., Beckstein, O.: Path Similarity Analysis: A Method for QuantifyingMacromolecular Pathways. PLoS Computational Biology , e1004568 (Oct 2015)14. Sriraghavendra, E., K., K., Bhattacharyya, C.: Fréchet distance based approach for searching online hand-written documents. In: Proceedings of the Ninth International Conference on Document Analysis and Recog-nition - Volume 01. pp. 461–465. ICDAR ’07, IEEE Computer Society, Washington, DC, USA (2007), http://dl.acm.org/citation.cfm?id=1304595.1304769
15. Wikipedia: Frechet_distance, https://en.wikipedia.org/wiki/Fréchet_distance Additional Algorithms of interest
Even though the source of this article, along with the unabridged code will be made publicly available uponpublication at the url https://github.com/FineGrainedAnalysis/Frechet , we copy here some extractsof the code, which can help the reader to understand the implementation and the experiments performed.
A.1 Dynamic Program Matrix
We describe in Algorithm 4 the
Python implementation of an algorithm to approximate the
DiscreteFréchet
Matrix between two sequences of points, by computing only values of the dynamic programwithin a band of width w around the diagonal, and limiting the recursion to distances smaller than a threshold t . The interest of this algorithm is not its running time, which is within Θ ( n × m ) given that it initializes andreturns the whole matrix of the dynamic program, but in the pedagogical value of its output, which yieldsa visualization of the space explored by Algorithm 3. In particular, this algorithm was used in Section 5 togenerate the matrices presented in Figures 1, 2 and 3. A.2 Random Generation of Long Edged Curves
We describe in Algorithm 5 the
Python code used to generate long edged instances in Figures 1, 2 and 3 ofSection 5. 10 lgorithm 4
Adaptive algorithm to approximate the
Discrete Fréchet