How this calculation works
Discrete Frechet distance compares ordered curves through a monotone coupling of their vertices. The calculator minimizes the largest paired Euclidean separation and reconstructs an optimal coupling path. Because order and endpoints matter, this is different from closest-point, Hausdorff or continuous curve distance.
D(i,j)=max(distance(a_i,b_j),min(D(i−1,j),D(i,j−1),D(i−1,j−1))).A worked example
Two parallel two-vertex segments (0,0),(1,0) and (0,1),(1,1) have discrete Frechet distance one. Pairing corresponding endpoints reaches that bound. Reversing one curve changes the allowed ordered coupling and can change the answer even when the same geometric point sets remain.
Good to know
Two nonempty 2D or 3D vertex sequences, at most 100 vertices each. Dynamic programming is exact for the supplied floating-point distances. It is the discrete vertex version, not continuous Frechet distance; refining a polyline can change the discrete result.
Reference: Eiter and Mannila: Computing Discrete Fréchet Distance (opens in a new tab) ↗
A coupling must advance through both ordered curves
A legal coupling begins with both first vertices and ends with both last vertices. At each step it advances in the first sequence, the second sequence or both, never backward. This monotone rule preserves traversal order, making the distance sensitive to sequence direction even when the two curves contain the same unordered points.
Vertices may be repeated in the coupling by holding one curve’s index while the other advances. That represents a pause in one traversal, not a new geometric vertex or a backward jump. It allows curves with different numbers of samples to be compared without requiring a one-to-one correspondence between their vertex lists.
The Closest pair of points calculator from coordinates covers the nearby task. Closest-pair distance ignores order; discrete Frechet compares complete ordered curves under a monotone matching.
The maximum separation defines a bottleneck objective
The cost of a coupling is its largest paired Euclidean distance. Dynamic programming selects the least possible such bottleneck, rather than minimizing the sum or average of paired distances. A single unavoidable separated endpoint can therefore determine the answer even when most of the two sequences lie very close together.
The recurrence stores the best predecessor among three legal moves and then takes the maximum with the current pair separation. Reconstructing those predecessors returns an explicit optimal coupling. Checking its monotonicity, endpoints and maximum separation provides a result certificate separate from the final matrix entry alone.
Discrete and continuous distances are different
Only the supplied vertices are paired. A continuous Frechet calculation also considers positions along segment interiors and can produce a different value. Adding intermediate vertices can change the discrete answer even when the drawn polyline shape is unchanged, so sample resolution belongs in any comparison between data sets.
Parallel short segments provide a hand-checkable distance one, while independent tiny tests enumerate every monotone coupling. Reversing one input tests order sensitivity. This page does not substitute closest-point or Hausdorff distance, infer a physical motion speed, or promise that coordinate uncertainty has been incorporated into the bottleneck value.
Define the allowed vertex coupling
A discrete coupling pairs vertices from the two ordered sequences, starting at (0,0) and ending at their last indices. Each step advances the first index, the second, or both, without moving backward. Its cost is the largest Euclidean distance among paired vertices. Discrete Fréchet distance minimizes that bottleneck over all such couplings.
The order constraint distinguishes it from a nearest-neighbor or Hausdorff comparison of unordered point sets. Both endpoints must be included, so their distances supply immediate lower bounds. Repeated use of one vertex while the other sequence advances is permitted; skipping an intermediate vertex of a sequence entirely is not.
Calculate the parallel-segment example and reverse it
For A=(0,0),(1,0) and B=(0,1),(1,1), pairing corresponding endpoints gives distances one and one. No coupling can beat one because the starting endpoints are already one unit apart, so the discrete distance is exactly one.
Reverse B to (1,1),(0,1) while leaving A unchanged. The starting and ending endpoint distances become √2, so every coupling costs at least √2. Pairing the endpoints diagonally attains that bound. The same geometric segment thus gives a different result when its traversal order is reversed. This is expected for ordered trajectories, not a failure of geometric distance symmetry between A and B.
Trace the dynamic-programming recurrence
Let dij be the distance between vertices ai and bj. The best bottleneck reaching pair (i,j) is Cij=max(dij,min(Ci−1,j,Ci−1,j−1,Ci,j−1)), with appropriate boundary rows and columns. The inner minimum chooses the best predecessor; the outer maximum includes the current pair’s distance in the path bottleneck.
Backtracking predecessors returns one optimal coupling. If several predecessors tie, different optimal couplings can exist with the same distance. A returned pairing therefore certifies an achievable bottleneck, while the completed recurrence proves no smaller coupling is possible for the supplied discrete vertices. It does not produce a time synchronization model or a summed trajectory error.
Separate discrete vertices from continuous curves
Continuous Fréchet distance permits positions between vertices along segments. This form only pairs supplied vertices, so its value is at least the continuous value for the corresponding polylines and can differ from it. The linked continuous-curve reference explains the broader concept; it is not the numerical algorithm claimed by this discrete page.
Adding intermediate vertices can change the discrete answer even if the underlying geometric polyline is unchanged. Coordinate units and scaling must match across both sequences, and 3D inputs must be three-dimensional in both. Noise, geographic projection and unequal sampling density can influence interpretation. The result measures an order-preserving geometric bottleneck, not statistical similarity or a probability that two tracks have the same source.
Read more: CGAL: comparison with continuous Fréchet distance (opens in a new tab) ↗
A few questions, answered
Is this continuous Frechet distance?
No. It couples only the supplied ordered vertices.
Can reversing one curve change the answer?
Yes. The coupling must preserve both input traversal orders.
Is this continuous Fréchet distance?
No. It is the discrete vertex version. Positions inside segments are not candidate coupling points, and refining the vertex sampling can change the result.
Why does reversing one trajectory change the answer?
Couplings must move forward through both sequences and include their endpoints. Reversal changes that traversal order even when the drawn segment is the same.