Time complexity of the Analyst's Traveling Salesman algorithm

The Analyst's Traveling Salesman Problem asks for conditions under which a (finite or infinite) subset of $\mathbb{R}^N$ is contained on a curve of finite length. We show that for finite sets, the algorithm constructed by Schul (2007)and Badger-Naples-Vellis (2019) that solves the Analyst's Traveling Salesman Problem has polynomial time complexity and we determine the sharp exponent.


Introduction
The (Euclidean) Traveling Salesman Problem (TSP) (Lawler, Lenstra and Rinnooy Kan [16], Gutin and Punnen [12], and Applegate, Bixby, Chvátaland and Cook [1]) asks to find the shortest path through a set V of n points in R N that starts and ends at a given vertex v 0 of V .Apart from its natural applications in itinerary design, and its influence on operations research, and polyhedral theory, in the last 50 years the TSP has gained great prominence in computer science due to its immense computational complexity.For example, it is well known that the TSP is NP-hard, see Garey, Graham, and Johnson [8] and Papadimitriou [20]; that is, it is at least as difficult as the hardest problems in NP (the class of all problems that can be solved by a non-deterministic Turing machine in polynomial time O(n k ) for some k ∈ N).
What is the minimum amount of time (depending on n) which is required to obtain a solution of the TSP? Can it be polynomial (ie O(n k ) for some k ∈ N)? Obviously, one could simply try all possible paths but that would require time comparable to (n − 1)! which is far from being polynomial.The Bellman-Held-Karp algorithm [6,13] improves the latter bound to O(n 2 2 n ).However, it is still unknown whether a polynomially complex algorithm exists.by increasing the running time by O(n N ).See also Bartal, Gottlieb and Krauthgamer [5] for relevant results.The Analyst's Traveling Salesman Problem (ATSP) (Jones [15]) is a generalization of the TSP where it is asked to find a curve of finite length that contains a given (finite or infinite) set V ⊂ R N .While the TSP (which is the finite case of ATSP) always admits a solution, the same is not true in general for the ATSP.For instance, if V is an unbounded set, then clearly every curve that contains V must be unbounded itself, hence with infinite length.Perhaps less intuitively, smaller, but still infinite, sets may not admit a solution.For example, if V is the set of all points in the unit square [0, 1] 2 with rational coordinates, it is not hard to see that V is bounded and countable but there exists no rectifiable curve that contains V .
The classification of sets in R N for which the ATSP can be solved, was done by Jones [15] (for R 2 ) and by Okikiolu [19] (for higher dimensional spaces).Ever since, this classification has played a crucial role in the development of geometric measure theory, and has found applications in many facets of analysis including complex analysis, dynamics, harmonic analysis and metric geometry.The work of Jones and Okikiolu provides an algorithm that, for any finite set V ⊂ R N yields a tour that is at most C(N) times longer than the optimal path.Here C(N) is a constant that depends only on the dimension N .The Jones-Okikiolu algorithm is based on a local version of the Farthest Insertion algorithm (Johnson and McGeoch [14]).Later, Schul [22] provided a modification of the algorithm so that the ratio of the length of the yielded path over the length of the optimal path is bounded by a constant C independent of the dimension N .Variation of this algorithm also appears in the work of Badgers, Naples and Vellis [3].Here and for the rest of this paper, we refer to any of these two variations as the ATSP algorithm.The purpose of this note is to show that the ATSP algorithm, in the case that V is finite, has polynomial time complexity.Theorem 1.1 The time complexity of the ATSP algorithm is O(n 3 ).
We remark that although time-wise this algorithm is fast, the ratio constant of the yielded path over the optimal path has not been computed and is much larger that Christofides' 3/2 ratio.In fact, in our algorithm, the yielded path has length at most (300) 9/2 log 300 times the length of the smallest spanning tree.Moreover, the exponent 3 in our theorem is sharp and can not be lowered; see Section 5.4.
An interesting connection to the Jones-Scul algorithm was given by Gu, Lutz and Mayordomo [11] who classified the sets V that admit a solution to a computable extension of the ASTP.This variant of the problem characterizes the sets which are contained in a rectifiable computable curve.As we are concerned only with finite sets here, our algorithm already produces computable curves.

Outline of the ATSP algorithm
Fix a set V = {v 1 , . . ., v n } ⊂ R N .The algorithm (described in detail in Section 5) computes connected graphs G k = (V k , E k ) with k = 1, . . ., m for some m ≤ n, so that the last graph satisfies V m = V .First, we compute R 0 = 5 max{|v| : v ∈ V} which takes O(n) time.It is clear that V ⊂ [−R 0 , R 0 ] N .The construction of graphs now is roughly as follows.
Step 1: For the first graph we have If U 1 = ∅, then proceed to the Final Step.Otherwise proceed to the next step.
Step k + 1: Inductively, we assume that for some k ∈ N, we have defined an integer We use results in Section 3 to define an integer n k+1 > n k , a set V k+1 that contains V k and is contained in V , and a set Here and for the rest of this paper, dist H (A, B) denotes the Hausdorff distance between closed sets A, B ⊂ R Next, using results in Section 4, we define for each v ∈ V k a number α that measures how "flat" the set V k+1 is around the point v.This notion of flatness is inspired by the Jones beta numbers in the work of Jones [15] and Schul [22].
Next, following the constructions in Schul [22] and Badger, Naples and Vellis [3], we create a connected graph G k+1 = (V k+1 , E k+1 ).Roughly speaking, if around some node v of G k , the set V k+1 looks flat (ie the number α is small), then the graph G k+1 around v should also be flat; otherwise, we add new edges around v so that the new graph is connected.We take care so that the total number of new edges is at most twice the total number of new points.

Final
Step: Arriving at this step, we have created a graph , we arrive at the final step in at most n steps.We show that each step above takes O(n 2 ) time, and therefore, we obtain G m in O(n 3 ) time.Now we use an algorithm in Section 2.2 to parameterize G m in O(n 3 ) time.

Hölder curves
It should be noted that the work of Jones [15], Okikiolu [19], and Schul [22] provides the sets for which a solution exists but not the solution itself when the set is infinite.That is, they classify the sets which are contained in curves of finite length, but do not provide the parametrization of the curves.Recently, the second named author with Badger and Naples [3] constructed an algorithm that, for those sets V that have a solution in ATSP, produces a solution path f : [0, 1] → R N which is at most C times longer than the optimal path with C independent of N .In this algorithm, one obtains parameterizations ( f k ) for all graphs G k and not just one of them.Moreover, the parameterizations obtained satisfy the inequality Although this approach is more complicated than the one of Jones and Okikiolu, it comes very handy in designing Hölder parameterizations of sets such as the space-filling Peano curve.For finite sets, the algorithm of constructing ( f k ) has also polynomial complexity (and in fact with the same exponent) but we will not pursue this direction here.

Preliminaries on graphs
A (combinatorial) graph is a pair G = (V, E) of a finite vertex set V and an edge set:

Components of a graph
Given a graph G = (V, E) we describe an algorithm that returns the connected components of G.
Lemma 2.1 There exists an algorithm that determines the components of , there are two possible cases.
(1) If there exists e ∈ E \ E 1,i such that e has an endpoint in V 1,i , then we set (2) If there does not exist e ∈ E \ E 1,i such that e has an endpoint in V 1,i , then we stop the procedure and set For each i, we make sure in O(card V 1 ) that no vertex appears twice.The time needed for the calculation of V 1 is at most a constant multiple of: and we repeat the process again to obtain (V 2 , E 2 ).We continue this way until we exhaust all points of V .Since the V i 's are disjoint, the sum of their cardinalities is card V .Thus, the total time needed for the algorithm to complete is at most a constant multiple of:

Two-to-one tours on connected graphs
Given a connected graph G = (V, E), we describe here an algorithm that gives a tour over all edges of G so that each edge is traversed exactly twice and once in each direction.
Lemma 2.2 Let G = (V, E) be a finite connected graph and let v 0 ∈ V .There exists an algorithm which in O((card V)(card E) 2 ) time produces a finite sequence (a i ) 2M+1 i=1 of points in V with M = card E that satisfies the following properties.
Assume that for some odd k ∈ {0, 1, . . ., M − 1} we have defined a set E k ⊂ E and a finite sequence (a k,i ) 2k+1 i=1 with the following properties.
Find e ∈ E k and j ∈ {0, 1, . . ., 2k+1} such that a k,j ∈ e.Since G is assumed connected, such j and e exist and the search for them would take at most O(card E card V) time.Let v be the unique element of e \ {a k,j }.Define now E k+1 = E k \ {e} and: The construction of E k+1 and the sequence (a k+1,i ) 2k+3 i=1 takes O(card E) time.By design and the inductive hypothesis, each edge in E \ E k+1 is traversed exactly twice.In particular, the properties (1)-(3) above are true for k + 1.This process terminates when k = M .The total time required is a constant multiple of: For i = 1, . . ., 2M + 1 set a i = a M,i .Note that E M = ∅.By induction, every edge of E = E \ E M is traversed twice, once in each direction.Since we traverse every edge of E, we have that {a 1 , . . ., a 2M+1 } = V and the proof is complete.

Construction of scales and nets
Given ϵ > 0, we say that a set X ⊂ R N is ϵ-separated if for any x, y ∈ X we have |x − y| ≥ ϵ.Given a set V ⊂ R N and ϵ > 0, we say that a set Recall the definition of Hausdorff distance from Section 1.1.In the next lemma we describe an algorithm that gives nets for a given set V .
Set X ′ = X n−l+1 and U ′ = U ′ n−l+1 .The construction of X ′ , U ′ takes O(n 2 ) time to complete.It remains to verify the conclusions of the lemma.
By the definition of d , there exists at least one element u in U such that |x − u| ≥ 2 −k ϵ for all x ∈ X .Therefore, the set X ′ \ X is nonempty.Moreover, it is clear that X ′ is a (2 −k ϵ)-separated set.To show that X ′ is maximal, assume for a contradiction that there exists v ∈ V such that |x − v| ≥ 2 −k ϵ for all x ∈ X ′ .Then, there exists m ∈ {1, . . ., n − l} such that x = c n−l−m+1 .But then, by (3-2), x would end up in X ′ which is false.The lower bound of (3-1) follows from the 2 −k ϵ-separability of X ′ and the fact that X ′ \ X ̸ = ∅.For the upper bound of (3-1) assume for a contradiction that there exists x ′ ∈ X ′ such that |x ′ − x| ≥ 2 1−k ϵ for all x ∈ X .Then, clearly x ′ ∈ V \ X ⊂ U and it follows that d ≥ 2 1−k ϵ.But that contradicts the minimality of k since k − 1 could also work.

Flatness modules and flat pairs
In this section we examine a notion of local flatness introduced by Jones [15] and further developed by Schul [22] and Badger and Schul [4].For the rest of this section we fix C 0 = 300, a finite set V ⊂ R N consisting of n elements, an ϵ-net X ⊂ V , and a (2 −k ϵ)-net X ′ ⊂ V such that X ⊂ X ′ and: In [22] Schul defined for each v ∈ X a number that measures the (normalized) thickness of the thinnest cylinder that contains the set: In our case, the numbers that we define measure the same thing with one difference; we will only consider a finite set of cylinders that contain B v,X ′ (as opposed to all cylinders) and we will choose the thinnest one.Nevertheless, the two flatness modules are close to each other; see Lemma 4.2.

Flatness modules
For the rest of this section, L is an integer with L ≥ 40C 0 √ N − 1 and G = {−2L, . . ., 2L} N .Given two distinct points y 1 , y 2 ∈ R N , we denote by ℓ(y 1 , y 2 ) the unique line that passes through y 1 , y 2 and define the normalized distance: where Essentially, α v,X ′ measures the smallest distance of the set B v,X ′ to all lines going through a fine grid of the cube We set ℓ v,X ′ to be the line passing through points x, y ∈ ϕ(G) with x ̸ = y that minimize the quantity D(x, y).
Proof We start by constructing the sets B v,X ′ .We check over all points u ∈ X ′ whether or not |v − u| < C 0 2 −k ϵ.Then the total time needed to construct the set B v,X ′ is O(card X ′ ).Since the set G is finite and independent of n, the calculation of α v,X ′ and of ℓ v,X ′ takes O(1) time.This completes the proof of the lemma.
Remark 4.1 Since for each v ∈ X we have to go through the entire set X ′ in order to construct B v,X ′ , the computations of the preceding lemma are sharp; that is, there exists universal C > 0 such that it takes at least C card X ′ time to compute B v,X ′ .
Lemma 4.2 If there exists a line ℓ such that Proof Suppose that ℓ is a line with max x∈B v,X ′ dist(x, ℓ) ≤ (1/20)2 −k ϵ.Without loss of generality, we may assume that ℓ intersects the cube v + C 0 2 −k ϵ[−1, 1] N ; otherwise we replace ℓ by a line parallel to ℓ that intersects the boundary of the cube and is closer to the set B v,X ′ .Then, ℓ intersects the boundary of the cube

Edges coming from E k
Recall from Section 4 that C 0 = 300.For each element e = {u, u ′ } ∈ E k , we compute |u − u ′ | and the two numbers α u,V k+1 and α u ′ ,V k+1 .
and α u ′ ,V k+1 are more than 1/16, then we place e in E (1)  k+1 .This case takes O(n) time.We set V k+1 (e) = ∅; this set will not play a role in the algorithm but we define it for consistency.
) is less or equal to 1/16, then we calculate B u,V k+1 ∪ B u ′ ,V k+1 and ℓ u,V k+1 .We also calculate an isometric affine map Ψ that takes u to the origin, takes u ′ to a point with positive first coordinate, and takes the line ℓ u,V k+1 onto the x 1 -axis.Then we determine those points u 1 , . . ., u l ∈ B u,V k+1 ∪ B u ′ ,V k+1 such that the first coordinates satisfy: By Badger and Schul [4,Lemma 8.3] we know that no distinct points Ψ(u i ), Ψ(u j ) have equal first coordinates so the inequalities above are justified.We set V k+1 (e) = {u 1 , . . ., u l } and we add the edges {u, u 1 }, . . ., {u l , u ′ } in E (1)  k+1 .The calculation of α u,V k+1 and α u ′ ,V k+1 , as well as the calculation of B u,V k+1 , B u ′ ,V k+1 takes O(n) time.The calculation of ℓ u,V k+1 , Ψ, and the subsequent ordering takes O(1).(However, l is bounded by a constant independent of N ; see [3,Remark 3.2]).Therefore, this case takes O(n) time.
In total, the computation of E (1)  k+1 takes O(n) card E k = O(n 2 ) time, with the associated constants depending only on N .Moreover: Remark 5.1 Let e, e ′ ∈ E k satisfy the assumptions of the second case.Then by [3, Lemma 3.3], V k+1 (e) ∩ V k+1 (e ′ ) = ∅.

Edges coming from points in F k
For each element u in F k we calculate the closed ball B u,V k+1 and the associated line ℓ u,V k+1 which takes O(n) time.Calculate an isometric affine map Ψ : R N → R N that takes the line ℓ u,V k+1 to the x 1 -axis, and u to a point with zero first coordinate.This takes O(1) of time.If there exists u ′ , u ′′ ∈ B u,V k+1 ∩ V k such that ⟨Ψ(u ′ )⟩ 1 < 0 < ⟨Ψ(u ′′ )⟩ 1 , then no new edges are obtained from u and we move to the next element of F k .Otherwise, we work as follows.
(1) If there exists no u ′ ∈ B u,V k+1 ∩ V k such that ⟨Ψ(u ′ )⟩ 1 < 0, then enumerate the points u 1 , . . ., u l ∈ B(u, 2 1−n k+1 R 0 ) such that and add the edges and add the edges k+1 .If none of the above is true, then no new edges are obtained from u and we move to the next element of F k .If both are true, we perform both of them.By [3, Remarks 3.4 and 3.5], we have that l ≤ 6.Therefore, the computation of points u i , their enumeration, and addition of edges takes O(1) time.The set of all the points in V k+1 \ V k coming from both of these cases above (if any) is denoted by V k+1 (u).
We repeat the same process for all points in F k and the construction of E (2)  k+1 is done in Remark 5.2 By Badger, Naples, and Vellis [3, Lemma 3 Before proceeding to the final set E (3)  k+1 we enumerate:

Edges coming from N k : first step
Define the set: The construction of this set requires O(n) time and its cardinality is O(1).We now go over the set E (1)  k+1 ∪ E (2)  k+1 formed above and if a point v ∈ V ′ k+1 (u 1 ) is contained in an edge of E (1)  k+1 ∪ E (2)  k+1 , then we remove it from the set V ′ k+1 (u 1 ) and in this way we form the set V k+1 (u 1 ) in O(n) time.By the doubling property of R N , card V k+1 (u) = O(1).
A Ramirez and V Vellis Moreover, from the previous subsections we already have that every point in V k is already contained in an edge of E (1)  k+1 ∪ E (2)  k+1 .Therefore: ) is empty, then we are done with u 1 and we move to u 2 .Otherwise, we construct the set: Since there are O(1) points in V k+1 (u), by Lemma 4.3 it takes a total of O(n) time to determine u∈V k+1 (u 1 ) Flat(u, V k , V k+1 ).We make sure that the latter set does not contain the same edge twice and we denote it by Flat(k + 1, u 1 ).Since the cardinality of Flat(k + 1, u 1 ) is O(1), this can be done in O(1) time.Define Ṽk+1 (u 1 ) to be the union of V ′ k+1 (u 1 ) and the set of all points in V k+1 that belong to an edge in Flat(k + 1, u 1 ).
Next, we form the graph G k+1 (u 1 ) = ( Ṽk+1 (u 1 ), Flat(k +1, u 1 )).We apply the algorithm of Lemma 2.1 which in O(1) time returns the components of G k+1 (u 1 ).If there is only one component, then we set E k+1 (u 1 ) := Flat(k + 1, u 1 ) (making sure in O(1) time that no edge appears twice) and we add all edges of E k+1 (u 1 ) (if any) in E (3)  k+1 and we move to u 2 .If there are p components with p ≥ 2, then we fix a point u 1,i in each component and we set and we add all edges of E k+1 (u 1 ) in E (3)  k+1 .
Recall that each point in V k+1 (u 1 ) can be in at most 2 edges of Flat(k + 1, u 1 ).Therefore, it is not hard to see that: card(E k+1 (u 1 )) ≤ 2 card(V k+1 (u 1 )) If l = 1, then the definition of E (3)  k+1 is complete we move to Section 5.2.6; otherwise and we move to u 2 .

Edges coming from N k : inductive step
Suppose that we have already added edges to E (3)  k+1 from vertices u 1 , . . ., u p−1 with p ≤ l.The definition of the set V k+1 (u p ) is the same as with V k+1 (u 1 ) with one important exception: this time we go over the set E (1)  k+1 ∪ E (2)  k+1 ∪ E (3)  k+1 instead of just E (1)  k+1 ∪ E (2)  k+1 .Therefore, (5-3) The rest of the construction is verbatim the same as before and we add to E (3)  k+1 a new (possibly empty) set of edges E k+1 (u p ) with  card(E k+1 (u p )) ≤ 2 card(V k+1 (u p )).

Final Step:
To finish the proof of Theorem 1.1, we remark that for the final graph G m = (V m , E m ) that we obtained, we have that V m = V and card E m = O(n).Therefore, the algorithm of Lemma 2.2, produces the desired tour in O(n 3 ) time.This completes the proof of Theorem 1.1.

Sharpness of exponent 3
Here we discuss why the time complexity O(n 3 ) is sharp.We will do this by analyzing the computations of the flat pairs and flatness modules.Note that the complexity of O(n 3 ) appears during many other steps of the algorithm as well (e.g.Lemma 2.1 and Lemma 2.2).
Let n be a positive integer and suppose that for all i ∈ {1, . . ., n} , card V i = i.At step k, we perform the calculation of sets Flat(v, V k , V k+1 ) for each v ∈ V k which, by Remark 4.1, requires C card V k+1 time for each such v, and for some fixed constant C > 0. Therefore, the computation of all flat pairs at step k requires C(card V k )(card V k+1 ) computations.Therefore, our total computations over all steps are: N : dist H (A, B) = max sup x∈A inf y∈B |x − y|, sup y∈B inf x∈A |x − y| Journal of Logic & Analysis 16:2 (2024) i=1,...,n−l min j=1,...,l |x j − u i | Since both sets X, U have cardinalities at most n, the computation of d takes at most O(n 2 ) time.Let k be the smallest integer such that 2 −k ϵ ≤ d ; the computation of k clearly takes O(1) time.By minimality of k we have that 2 1−k ϵ > d .