An algorithm with improved complexity for pebble motion/multi-agent path finding on trees

The pebble motion on trees (PMT) problem consists in finding a feasible sequence of moves that repositions a set of pebbles to assigned target vertices. This problem has been widely studied because, in many cases, the more general Multi-Agent path finding (MAPF) problem on graphs can be reduced to PMT. We propose a simple and easy to implement procedure, which finds solutions of length O(knc + n^2), where n is the number of nodes, $k$ is the number of pebbles, and c the maximum length of corridors in the tree. This complexity result is more detailed than the current best known result O(n^3), which is equal to our result in the worst case, but does not capture the dependency on c and k.


Introduction
Multi-Agent Path-Finding (MAPF), also called pebble motion on graphs, or cooperative path-finding, is the problem of finding a collision-free movement plan for a set of agents (or pebbles) moving on a graph.This problem has been widely discussed, together with its many variants (Stern et al., 2019), on various types of graphs.For most graph classes, finding an optimal solution of MAPF (that is, a solution with a minimum number of moves) is NP-hard (Yu & LaValle, 2013).Instead, the complexity of checking MAPF feasibility depends on the specific graph class.For instance, it is polynomial on undirected graphs (Kornhauser et al., 1984), on strongly biconnected directed graphs (Botea & Surynek, 2015), and on strongly connected directed graphs (Ardizzoni et al., 2022).Instead, it is NP-hard in the general case of directed graphs (Nebel, 2020).Optimal and suboptimal algorithms have been proposed in the last forty years (Achá et al., 2022;Alotaibi & Al-Rawi, 2016;Ardizzoni et al., 2022;Auletta et al., 1999;Botea & Surynek, 2015;Botea et al., 2018;De Wilde et al., 2014;Kornhauser et al., 1984;Sharon et al., 2015).
We focus on one of the simplest versions of this problem, the pebble motion on a tree (PMT) (Auletta & Persiano, 2001;Auletta et al., 1999;Goraly & Hassin, 2010;Khorshid et al., 2011;Krontiris et al., 2013), which is defined as follows.Let T = (V, E) be a tree with n vertices and k < n distinct pebbles, numbered 1, . . ., k, placed on distinct vertices.A move consists in transferring a pebble from its current position to 1 arXiv:2307.12770v1[cs.MA] 24 Jul 2023 an adjacent unoccupied vertex.The PMT consists in finding a sequence of moves that repositions all pebbles to assigned target vertices.In particular, we focus on the problem of finding a feasible solution, not necessarily optimal.
Although PMT is one of the simplest versions of MAPF, it is quite relevant.Indeed, various algorithms that solve MAPF on more general graphs are based on a reformulation of MAPF as a PMT, over a suitably defined tree (Ardizzoni et al., 2022;Goraly & Hassin, 2010;Krontiris et al., 2013).We will further discuss this in Section 6.In literature, there exist many complete sub-optimal algorithms for solving PMT.In particular, Kornhauser and coauthors (Kornhauser et al., 1984) present a procedure which solves it in O(n 3 ) moves.However, the approach is not described algorithmically, but must be derived from a number of proofs in the paper (Röger & Helmert, 2012).This requires significant effort, and, to the best of our knowledge, Kornhauser's results have never been fully implemented.Auletta and coauthors (Auletta et al., 1999) present an algorithm for deciding the feasibility of PMT, from which a solution can be derived requiring O(k 2 (n− k)) moves.However, the paper does not explicitly explain how to find such a solution.Korshid and coauthors (Khorshid et al., 2011) present an algorithm for PMT (called TASS) that is easy to understand and implement.However, solutions provided by TASS require O(n 4 ) moves.
Therefore, after Kornhauser and coauthors in 1984, no one has proposed a clear and detailed algorithm with length-complexity O(n 3 ).The result of Kornhauser is a fundamental step in the study of PMT complexity.However, under a more practical point of view, the implementation of a simple and efficient algorithm for solving PMT with length-complexity at least O(n 3 ) remains an open problem.The aim of this paper is to address this problem by proposing an efficient, clear, and simple PMT solver, with a more detailed complexity result with respect to Kornhauser's.In this work, we also deal with two variants of PMT: the motion planning problem and the unlabeled PMT.In the first one, a single marked pebble has to reach a desired target vertex, while non-marked pebbles are obstacles that need be moved out of the way to re-position the marked one (Auletta & Persiano, 2001;Papadimitriou et al., 1994;Wu & Grumbach, 2009, 2010).In the second one (also known as U-GRAPH-RP (Cȃlinescu et al., 2008;Dumitrescu, 2013) or anonymous MAPF (Ma & Koenig, 2016)), pebbles are not labeled (i.e., there is a set of target positions D, and each pebble has to reach a vertex in D, not specified in advance).
Statement of contribution.We present three main contributions: 1.In Section 4, we propose the sub-optimal CATERPILLAR algorithm to solve the motion planning problem on a tree.It provides solutions with O(nc) moves, where c is the maximum length of the corridors (i.e., paths whose internal nodes all have degree two, and whose end nodes have degree different from two).We are able to guarantee this complexity since, when we move the marked pebble p to its target, we only move the obstacles that are along the path of p, sliding them section by section from one subset of vertices to another, avoiding unnecessary motions.
2. In Section 5, we propose a sub-optimal algorithm for PMT (called Leaves procedure for PMT).The idea of the Leaves procedure for PMT is to use the CATERPILLAR algorithm to move the pebbles to the leaves of the tree, used as intermediate targets.At the end, we solve an unlabeled PMT instance, which brings the pebbles to the original targets.This procedure is simpler and easier to implement than the one proposed by Kornhauser and coauthors (Kornhauser et al., 1984).In addition, we prove a more detailed complexity result than the one provided by Kornhauser and coauthors.Indeed, our algorithm finds solutions with a number of moves O(knc + n 2 ), which in the worst case is O(n 3 ).Therefore, the number of moves of these solutions depends on the tree structure and the number of pebbles.
3. In Section 6, we discuss a variant of the PMT problem, called PMT with transshipment vertices (ts-PMT).This variant is relevant since a MAPF instance on a generic graph can be reduced to an instance of this problem.ts-PMT can be solved with the Leaves procedure for PMT with some minor modifications.This permits us to provide an upper bound for the solution length of MAPF on graphs.

Problem Definition
Let T = (V, E) be a tree, with vertex set V and edge set E. We are also given a set P of pebbles and a set H of holes, and each vertex of T is occupied either by a pebble or by a hole, so that A configuration is a function A : P ∪ H → V that assigns to each pebble or hole the vertex occupied by it.A configuration is valid if it is one-to-one (i.e., each vertex is occupied by one and only one pebble or hole).The collection C ⊂ {P ∪ H → V } contains all valid configurations.Given a configuration A and u, v ∈ V , we denote by A[u, v] the configuration obtained from A by exchanging the pebbles (or holes) placed at u and v: As mentioned in the Introduction, a move is the movement of a pebble along an edge.For each edge (u, v) ∈ E we can define two possible moves, that are the two ordered pairs u → v and v → u.We indicate with Ê the set of all the moves on tree T .Function ρ : C × Ê → C is a partially defined transition function such that ρ(A, u → v) is defined if and only if v is empty (i.e., occupied by a hole).In this case ρ(A, u → v) is the configuration obtained by exchanging the pebble or the hole in u with the hole in v. Notation ρ(A, u → v)! means that the function is defined.In other words ρ Note that the hole in v moves along v → u, while the pebble or hole on u moves on v.
We represent a plan as an ordered sequence of moves.It is convenient to view the elements of Ê as the symbols of a language.We denote by E * the Kleene star of Ê, that is the set of ordered sequences of elements of Ê with arbitrary length, together with the empty string ϵ: We extend the function ρ : C × Ê → C to ρ : C × E * → C, by setting (∀A ∈ C)ρ(A, ϵ)! and ρ(A, ϵ) = A.Moreover, (∀s ∈ E * , e ∈ Ê, A ∈ C) ρ(A, se)! if and only if ρ(A, s)! and ρ(ρ(A, s), e)! and, if ρ(Ase)!, then ρ(Ase) = ρ(ρ(As), e).Note that ϵ is the trivial plan that keeps all pebbles and holes on their positions.We denote by |f | the length of a plan f (i.e., the number of moves of f ).We define an equivalence relation ∼ on E * , by setting, for s, t ∈ E * , s ∼ t ↔ (∀A ∈ C) ρ(A, s) = ρ(A, t).In other words, two plans are equivalent if they reconfigure pebbles and holes in the same way.Given a configuration A and a plan f such that ρ(A, f )!, a plan f −1 is a reverse of f if A = ρ(ρ(A, f ), f −1 ) (i.e., f −1 moves each pebble and hole back to their initial positions).We can also write f f −1 ∼ ϵ, so that f −1 behaves like a right-inverse.
Proposition 2.1.For any configuration A ∈ C and any plan f ∈ E * , such that ρ(A, f )!, there exists a reverse plan Proof.The thesis can be proved by induction as follows.If f ∈ Ê, then there exist We prove that the thesis is verified also for each plan of length n + 1.Indeed, if |f | = n + 1 then f = ge with |g| = n and e ∈ Ê.Therefore, there exist g −1 and e −1 the corresponding reverse plans such that |g −1 | = |g| and |e −1 | = |e|, and we can define f −1 := e −1 g −1 which is a reverse plan of f : Our main problem is pebble motion on a tree, which consists in finding a plan that re-positions all pebbles to assigned target vertices, avoiding collisions.For this problem, and the ones we will present later, the position of the holes is not relevant.Therefore, we introduce an equivalence relation ∼ between configurations and we indicate with Ã1 the equivalence class of A 1 .Definition 2.2.(PMT problem).Given a tree T , a pebble set P , an initial valid configuration Ãs , and a final valid configuration Ãt , find a plan f such that Ãt = ρ( Ãs , f ).
We also focus on two relaxations of the PMT problem: the motion planning problem and the unlabeled PMT problem.The former consists in finding a plan such that a single marked pebble reaches a desired target vertex, avoiding collisions with other pebbles, which are movable obstacles.The latter consists in finding a plan such that each pebble reaches any vertex belonging to the set of targets.
Definition 2.3.(Motion planning problem).Let T = (V, E) be a tree, P a set of pebbles, and Ãs an initial valid configuration.Given a pebble p and a target node t ∈ V , find a plan f such that t = ρ( Ãs , f )(p).
Definition 2.4.(Unlabeled PMT problem).Let T = (V, E) be a tree, P a set of pebbles, and Ãs an initial valid configuration.Given D ⊂ V , a set of destinations such that |D| = |P |, find a plan f such that D = ρ( Ãs , f )(P ).

Notation
Let T = (V, E) be a tree with n nodes and let u ∈ V .We denote by F (u) the connected components of the forest obtained from T by deleting u.For some v ∈ V \ {u}, T (F (u), v) is the connected component containing v, while C(F (u), v) is the set of remaining connected components of F (u) excluding T (F (u), v).
Given two nodes a, b ∈ V , we denote by π ab the set of vertices of the unique path in T from a to b, and with d(a, b) the length of this path.In particular, π ab is a corridor if a and b have degree different from two, while the internal nodes of the path all have exactly degree two.Moreover, π ab \ {a} is the set of all vertices of π ab , except for a.We denote by C(T ) the set of all corridors of T , and by c 1 the maximum corridor length: Let J ⊂ V be the set of junctions (i.e., nodes with degree greater than two).We define the subclass of corridors C(T ) ⊂ C(T ) that have only junctions as endpoints, and we denote by c 2 (T ) the maximum length of this subclass of corridors.Obviously, c 2 (T ) ≤ c 1 (T ).Note that corridors in C(T ) \ C(T ) are those for which at least one endpoint is a leaf of the tree.
Let us define the distance between a node s and a subset of nodes W ⊂ V as Then, a subset of V of cardinality q closest to W 1 is a set W such that where P(V ) denotes the power set of V (i.e., the set of all its subsets).

Assumptions
In all the problems we focus on, we assume that the following assumption holds: where c(T ) ∈ N is a constant depending on the structure of the tree T .In particular, if T is a path graph (i.e., a tree with two nodes of degree 1, and the remaining n − 2 nodes of degree 2) c(T ) := c 1 (T ).Otherwise, in all other cases, c(T ) is defined as follows: From now on, when we write c 1 , c 2 and c without the indication of a tree within the parenthesis, it is given as understood that the three parameters refer to the tree T on which we are solving the PMT problem, while for other trees we will explicitly indicate them within parenthesis .Kornhauser and coauthors (Kornhauser et al., 1984) showed that Assumption (2) is a necessary and sufficient condition for the feasibility of PMT on trees.Obviously, it follows that this condition is also sufficient for the feasibility of any instance of the unlabeled PMT problem, and of the motion planning problem.

Basic plans
Let T be a tree and A a configuration on it.Given a path we define the following plans: 1.If w ∈ A(H), Bring hole from w to v is defined as In other words, for each j from n − 1 to 1, if there is a pebble on u j , we move it on u j+1 .For instance, see the example of Figure 1.
2. If v ∈ A(P ) and π vw \ {v} ⊂ A(H), Move Pebble from v to w is defined as For instance, see the example of Figure 2.

Unlabeled PMT problem
Let P be a set of unlabeled pebbles on a tree T = (V, E).Let A s be the initial configuration and D be the set of destinations.We denote by S = A s (P ) the set of pebbles initial positions.The goal of the unlabeled pebble motion on trees is to move each pebble from its initial position to any position of D. In the following, we introduce an algorithm presented by Kornhauser and coauthors (Kornhauser et al., 1984).
1.If V is empty: terminate the procedure.
2. Select any leaf v of T .
Let p be the pebble on w.By definition of w, path π wv contains only pebble p.Therefore, move p to v and update S = S \ {w}.Then, "prune" v from T , i.e., V = V \ {v}.Go to Step 1.
Final configuration after bringing the hole from w to v. • if v ∈ S \ D. Find an unoccupied vertex u which is at minimum distance from v on T : Then, path π vu has pebbles on each vertex except u.Move each pebble on the path π vu towards u with plan α vu as defined in (4).This makes v unoccupied and u occupied.Then, set S = (S \ {v}) ∪ {u}, "prune" v from T , i.e., V = V \ {v}, and go to Step 1.
Since at most n moves are made at each execution of Step 2, and Step 2 is executed n times (at each iteration the cardinality of V is decreased by one), the total number of required moves is at most n 2 .Therefore, the complexity of this algorithm is O(n 2 ).

Gather holes problem
In this subsection, we focus on a particular case of the unlabeled PMT problem: the gather holes problem.Let T = (V, E) be a tree with n nodes, P a set of pebbles, and H Final configuration after moving the pebble from v to w. the set of holes.Let T = ( V , Ē) be a subtree with q = | V | ≤ |H|.Then, gather holes in T consists in bringing q holes of the tree to the nodes of T .
Definition 3.1.(Gather holes problem).Let T be a tree and T = ( V , Ē) be a subtree.Let P be a set of pebbles, and Ãs an initial valid configuration.Find a plan f such that V ∩ ρ( Ãs , f Even if gather-holes can be solved by the previous algorithm, we present a specific procedure that allows finding a feasible solution with a lower time-complexity.The solution plan removes pebbles from vertices of T , and replaces them with holes.To search for a short plan, it is convenient to bring holes that are already close to V .Therefore, we choose the holes in a set M such that M ∈ arg min i.e., M is a subset of vertices with cardinality q closest to V and containing only holes of the initial configuration.Denote by H the set of holes on M (A s ( H) = M ).Then, we want to find a plan Denoting by VP = A s (P ) ∩ V the initial set of occupied vertices of T , we can proceed as follows: 1.If VP is empty: terminate the procedure; Denote by p the pebble on u.If π uv ∩ V = {u}, then move each pebble on the path π uv towards v with plan α uv defined in (4), and update A s = ρ(A s , α uv ).
Otherwise, let w be the closest node to v of π uv ∩ V : move p from u to w with plan β uw defined in (11) (note that π uw \ {u} contains only unoccupied vertices); then, move each pebble on path π wv towards v with plan α wv .Finally, update A s = ρ(A s , β uw α wv ).This makes u unoccupied.
Since at most n moves (with n = |V |) are made at each execution of Step 2, and Step 2 is executed at most q times (with q = | V |), (since the cardinality of VP is reduced by one at each iteration), we have the following complexity result.
Proposition 3.2.The length complexity of the solution provided by the gather holes procedure is O(nq).Figure 3 presents an example of the execution of the procedure just described.The blue circles represent the holes, and H = {c, d, g} is a subset of holes closest to subtree T (Figure 3a).Another possible choice for H is, for example, H = {c, e, g}. Figure 3b shows the final configuration, in which the holes of H have been moved to the subtree.

Motion planning on trees
Let T = (V, E) be a tree, P a set of pebbles and H a set of holes.We assume that condition (2) of Section 2.2 holds.Recall that where c 1 is the maximum length of all the corridors and c 2 is the maximum length of the corridors with endpoints that are junctions.Let A s be an initial valid configuration.Given a pebble p on r = A s (p), and a target node t ∈ V , we show how to find a plan f such that t = ρ(A s , f )(p).To do that, we analyze two cases: We choose H = {c, d, g} the subset of holes closest to subtree T .
• a Figure 3: Example of Gather hole problem.We want to move three closest holes to the subtree T .
For each of the two cases we present a solution procedure (Procedure A and Procedure B ).The union of these procedures constitutes an algorithm to solve any instance of motion planning on trees, called the CATERPILLAR algorithm.
Case A. T (F (r), t) contains at least c holes.
The main idea of the algorithm is to clear, piece by piece, the path that goes from r to t, allowing the pebble to reach the target.We identify intermediate junctions on π rt (denoted by i k ), and "parking" positions (denoted by ℓ k ) which are neighbor nodes of i k , but do not belong to π rt .The pebble moves from one parking position to the next one, until it reaches the target.When the pebble is on ℓ k , we move out of the way all the obstacles that are on π i k i k+1 , so that we can freely move the pebble from ℓ k to ℓ k+1 .We identify a sequence of subsets of vertices on which the movement of the pebble from ℓ k to ℓ k+1 will be defined: each of them will contain the path from i k to i k+1 combined with the parking positions ℓ k and ℓ k+1 .These subsets (S 0 , . . ., S m ), called caterpillar sets, are such that: • the restriction of T to S k is a connected subtree for all k = 0, . . ., m; • |S k | = c + 1 for all k = 0, . . ., m − 1, and |S m | ≤ c + 1; • s ∈ S 0 and t ∈ S m ; • |S k ∩ S k+1 | ≥ 2 for all k = 0, . . ., m − 1, i.e., two consecutive sets have at least two nodes in common.
These properties guarantee that there are enough holes to clear the path and move the pebble from one parking position to the next one.

Construction of caterpillar sets
Along path π rt we select the node triple (i k , j k , ℓ k ): i k and j k represent the ends of a caterpillar set, while ℓ k is a parking position.We proceed as follows: 1. Let ℓ 0 = r, i 0 be the neighbor of r that belongs to π rt , and: • otherwise, let j 0 be the node on π rt such that d(i 0 , j 0 ) = c − 2. Set k = 0, j −1 = i 0 and go to Step 2.
Figure 4: We consider the motion planning problem with source vertex r and target vertex t on a tree with c = 5. S 0 , S 1 and S 2 are the caterpillar sets along path π rt .
Remark 4.1.Note that i k+1 is always well defined.Indeed, guarantees that there exists a junction on Now, let us find a lower bound for If m is even, Therefore, where δ is the diameter of the tree.If c ≥ 2, it follows that m = O( δ c ).Note that c = 1 only holds for the trivial case of the tree with 2 edges.
Nodes (i k , j k , ℓ k ) are used to delimit the borders of the caterpillar sets (see Figure 4), which are defined as follows: We can easily note that the union of all caterpillar sets is a caterpillar tree (i.e., a tree in which all the vertices are within distance 1 from a central path).Moreover, all the properties of the caterpillar sets are verified: • S k is a connected component of T , and so it is a subtree; (1) slide obstacles (2) move pebble (a) Initial configuration.First we have slide the obstacles from S k+1 \ S k to S k \ S k+1 , then we move the pebble from ℓ k+1 to ℓ k+2 .
S k S k+1 2. Let q j = |A s (H) ∩ V j | be the number of holes in T j : • if q j ≤ q, gather all the holes of T j in H j , which is a subset of V j of cardinality q j closest to the subset {s}: Set j = j + 1, q = q − q j and go back to Step 2; • otherwise, gather q holes of T j in H j which, in this case, is defined as a subset of V j of cardinality q closest to s.
3. choose v ∈ H j which has the maximum distance from s and move pebble p on v; 4. reinitialize s with node v and apply Procedure A.

Note that
Step 4 is feasible because in T (F (v), t) there are certainly at least c holes.Let n j be the number of nodes of T j .Then, recalling the length complexity of the gather holes procedure, Procedure B (without the final application of Procedure A) requires at most k j=1 n j q j moves to bring the holes in the neighborhood of s, and at most n moves to bring pebble p on v. Therefore, the length complexity of this procedure is O(nq) which, in the worst case, is O(nc).The final application of Procedure A does not modify the complexity result.Thus, we proved the following result.

Pebble motion on trees
Now we are ready to provide a procedure for the solution of PMT.We are given a tree T = (V, E), a pebble set P , an initial valid configuration A s , and a final valid configuration A t .As already mentioned, the PMT problem consists in generating a plan f such that A t (p) = ρ(A s , f )(p) ∀ p ∈ P .We will use the following strategy.
First, we solve an unlabeled PMT on T to bring the pebbles to an ordered set of intermediate targets, t1 , . . ., t|P | .Later, we will discuss the choice of these targets.We call g the corresponding plan.Note that we do not apply this plan, but will apply the inverse plan g −1 at the end of the procedure.Then, we solve a set of |P | motion planning problems on a sequence T k of subtrees of T .Over each subtree, we use the CATERPILLAR algorithm to move each pebble p ∈ P to one intermediate target t k (that occupies a leaf of T k ).After the execution of the corresponding plan, we remove target v from tree T k , obtaining tree T k+1 , and remove p from the set of pebbles.Finally, we apply the inverse plan g −1 on T .
We choose the intermediate targets such that trees T k satisfies the following properties, for k = 1, . . ., |P | − 1: • T k contains tk , tk+1 , . . ., t|P | but does not contain t1 , . . ., tk−1 ; Let L(T k ) be the set of all the leaves of the tree T k .We denote by V 1 = { tk : k ∈ {1, . . ., |P |}} the set of intermediate targets.We define them by the following procedure: The following proposition shows that Step 3 of the above procedure is well defined, i.e., it is always possible to find a leaf v of T k such that c(T v k ) ≤ c(T k ).Note that the result is valid for general trees and not only for the subtrees T k generated by the above procedure.
Proposition 5.1.For all k ∈ {1, . . ., |P | − 1}, there exists v ∈ L(T k ) such that c(T v k ) ≤ c(T k ), where T v k is the tree obtained by removing v from T k .
Proof.For each w ∈ L(T k ) we denote by n w the unique neighbor of w, and by deg(n w ) its degree.We define three subsets of leaves: We choose v as follows (see also Figure 7): , since by removing v, we just remove a corridor of length 1 (see Figure 7a); , since by removing v, we are reducing by one the length of one corridor in C(T k ) \ C(T k ) (see Figure 7b); Two cases are possible: 1. C(T k ) = ∅, so that T k is a star graph with a central node and three neighboring leaves.It holds that c(T k ) = 2. Removing one leaf v, T v k is a path graph of length 2, therefore c(T v k ) = 2 = c(T k ) (see Figure 7d).2. C(T k ) ̸ = ∅: then, it holds that c 1 (T k ) = c 2 (T k ) and, consequently, c(T k ) = c 2 (T k )+2.Moreover, there exists at least one corridor in C(T k ) such that one of its endpoints is a junction connected to exactly two leaves, since We choose v between one of the two leaves (see Figure 7c).In this case, We propose the following Leaves procedure for PMT, which breaks down the PMT problem into an unlabeled problem and a series of motion planning problems, and find plan f for any PMT instance.
Leaves procedure for PMT 1.Let V 1 be the set of intermediate targets found with the previous procedure.Find a plan g which solves the unlabeled PMT problem from the final configuration and let A t := ρ(A t , g) be the intermediate configuration.Note that for all k ∈ {1, . . ., |P |}, g would move a pebble from t i k to the intermediate target tk .
2. Set k = 1 and perform the following procedure: (b) using CATERPILLAR algorithm, solve the motion planning for pebble p i k from A s (p i k ) to tk , i.e., find a plan f k , over the tree T k obtained from T by removing nodes t1 , . . ., tk−1 , such that tk (d) set k = k + 1 and go back to Step a).
3. Apply g −1 , the inverse plan of g, which, for all k ∈ {1, . . ., |P |}, moves pebble p i k from tk to t i k .
Therefore, plan f which solves a given PMT instance is The complexity of the proposed procedure is stated in the following theorem.
Theorem 5.2.The length complexity of the proposed procedure for the solution of the PMT problem is O(|P |nc + n2 ).
Proof.Note that f k requires at most O(nc) moves for all k = 1, • • • , |P |.Indeed, each f k is the solution of a motion planning problem, which, in view of Propositions 4.3 and 4.4, is solved in O(nc) moves.Moreover, g −1 requires at most n 2 moves.Indeed, g is the solution of an unlabeled PMT, which requires O(n 2 ) moves, as seen in Section 3. Since g −1 is obtained from g by reversing its moves, it has the same length (see Observation 2.1).Then, the total number of moves is Figure 13 provides an example of application of the Leaves procedure for a PMT instance with three pebbles.
An interesting property of the Leaves procedure for PMT concerns the number of times each vertex is traversed by pebbles.As we further discuss in Section 6, the pebble motion problem on general graphs can be solved after converting it on a variant of PMT over trees.The bound on the number of times each vertex is crossed by the pebbles in the PMT problem over trees provided by the following proposition, allows deriving a complexity result also for the pebble motion problem over general graphs.Such complexity result will be the topic of a forthcoming paper.
Proposition 5.3.In any solution provided by the proposed procedure, each vertex is crossed O(|P |c) times by the pebbles.
Proof.Let us count how many times each vertex is crossed in the solutions of each problem described in the paper: 1. Basic plans.
• Bring hole from w to v (α vw ): each pebble along path π vw moves forward one position, therefore each vertex is crossed at most once.• Move Pebble from v to w (β vw ): one pebble moves on the path π vw , therefore each vertex is crossed at most once.
3. Gather c holes.In each iteration of Step 2 of the procedure described in Section 3.1, each vertex is crossed at most once because it performs α uv or β uw α wv .Since Step 2 is executed at most c times, each vertex is crossed O(c) times.(b) Procedure B. In Step 2 we solve a gather hole problem with q j holes, therefore each vertex is crossed O(q j ) times.Since k j=1 q j = q ≤ c, each vertex is crossed at most O(c) times. 5. Leaves Procedure.A solution of PMT given by this procedure is (see ( 9)).For each k ∈ {1, . . ., |P |}, f k is the solution of a motion planning problem provided by the CATERPILLAR algorithm, therefore each vertex is crossed O(c) times.Moreover, g −1 is the inverse of the solution of an unlabeled problem: therefore each vertex is crossed O(|P |) times.We can conclude that in the solution plan of PMT each vertex is crossed times.

PMT with Trans-shipment vertices
The more general MAPF problem can always be reduced to a variant of the PMT (called ts-PMT), both in the case of undirected graphs (Goraly & Hassin, 2010;Krontiris et al., 2013) and of directed graphs (Ardizzoni et al., 2022).Given a graph G, it is possible to convert it into a tree (called biconnected component tree), adding a new type of vertex called trans-shipment (Ardizzoni et al., 2022;Goraly & Hassin, 2010;Krontiris et al., 2013).In particular, each biconnected component of the graph is converted into a star subgraph, whose internal vertex is a trans-shipment (see Figure 9).This way, the original problem on graph G is converted into a problem over a tree with trans-shipment vertices.Once a solution of the problem over the tree is obtained, this can be converted back into a solution for the original problem.
For this reason, we need to study a variant of the PMT problem, the pebble motion on trees with trans-shipment vertices (ts-PMT), which is a PMT problem on a tree such that the vertex set is partitioned in trans-shipment and regular vertices.Definition 6.1.A trans-shipment vertex is a vertex with degree greater than one that cannot host a pebble: pebbles can cross this node, but cannot stop there.More formally, given a trans-shipment vertex s, 1. deg(s) ≥ 2;  2. ρ(A, (u → s)(w → v))! if and only if w = s, (u, s), (s, v) ∈ E, and The second property means that, if a pebble is moved to a trans-shipment vertex, then it must be immediately moved to another node.
We denote by V T the set of all the trans-shipment vertices and V R = V \ V T the set of regular vertices.We require that V T satisfies the following property This assumption is motivated by the fact that trans-shipment vertices are the internal vertices of the stars, so they cannot be adjacent to each other.Now we can formally define the PMT problem with trans-shipment vertices as follows.Definition 6.2.(PMT problem with trans-shipment vertices).Let T = (V, E) be a tree with V = V R ∪ V T , where the set of trans-shipment vertices V T is such that (10) holds.Given a pebble set P , initial and final valid configurations Ãs , Ãt such that Ãs (P ), Ãt (P ) ⊂ V R , find a plan f such that Ãt = ρ( Ãs , f ).This problem can be solved with the same procedure described in Section 5.However, some changes need to be made to ensure that the second property of Definition 6.1 is fulfilled.In the next subsections we show the changes we need to introduce into the previous procedures to address the presence of trans-shipment vertices.

Basic plans
We generalize the definition of the plan Bring hole from w to v to the case in which there is a trans-shipment vertex on the path π vw .For instance, if In other words, the only difference from the previous definition is that if a pebble move on u i , then it immediately moves to u i+1 .For instance, see the example of Figure 10, where node u 3 is a trans-shipment vertex.
Observation 6.3.Note that α vw can be defined only if w ∈ A(H) ∩ V R , which means that it is not allowed to bring hole from a trans-shipment vertex.Indeed, this could imply that in the final configuration a pebble lands on w.For the same reason plan Move Pebble from v to w (i.e., β vw ), which in this case does not change, can be defined  Green squares represent pebbles, blue circles represent holes.

Assumption
Observation 6.3 implies that the main difference of the new algorithm is that the holes on the trans-shipment vertices cannot be used in bring hole and gather hole operations, which are the basis for all the procedures that constitute the algorithm to solve PMT.For this reason, we define a new distance d which does not take into account transshipment vertices.Given a path π uv , d(u, v) counts how many regular vertices belong to the path: Consequently, we also define c1 and c2 which count corridor lengths according to the new definition of distance: (12)

Unlabeled PMT with trans-shipment vertices
To solve this problem, we use the same procedure described in Section 3 to solve the classical Unlabeled PMT.The only difference is in Step 2 in the case vertex v is a source but not a target (v ∈ S \ D).Here, we need an unoccupied vertex u in order to move each pebble on the path π vu towards it with plan α vu .In this case u must be a regular vertex, so that we need to replace (7) with:

Gather holes problem with trans-shipment vertices
We use the same procedure described in Section 3.1.However, the choice of set M defined in (6) needs to be replaced by: to guarantee that the holes in M are at regular vertices.

Motion planning problem with trans-shipment vertices
We must take into account the fact that trans-shipment vertices cannot host the marked pebble or the obstacles.Therefore, to ensure that the obstacle moves are feasible, we cannot only consider the cardinality of caterpillar sets, but the number of regular vertices they contain.To ensure this, we have to introduce the following modifications in the construction of the caterpillar sets: 1. replace d and c with d and c; 2. the request on the size of the caterpillar sets concerns only the regular nodes: 3. parking positions ℓ k cannot be trans-shipment vertices.At each step k, if the neighbors of i k not belonging to π rt are all trans-shipment vertices, then let ℓ k be one of the 2-hop neighbors of i k , which certainly exist in view of the first property of Definition 6.1 and are regular vertices because of assumption (10).Therefore, we can generalize the definition of caterpillar sets as follows: For instance, see Figure 11.
To solve the motion planning problem, we use Procedure A and Procedure B with some small tweaks: 1.In Procedure A: when we slide the obstacles, we move them from (S k+1 \ S k ) ∩ V R to (S k \ S k+1 ) ∩ V R .Indeed, we cannot bring holes from trans-shipment vertices.
2. In Procedure B : at each iteration we gather the holes that are on where Figure 11: We consider the motion planning problem with source vertex r and target vertex t on a tree with c = 5.Diamond shapes represent trans-shipment vertices.S 0 , S 1 and S 2 are the caterpillar sets along path π rt .

Experimental Results
We performed two distinct set of experiments, one regarding only the motion planning algorithm, one for the whole PMT algorithm.The algorithms have been implemented in Matlab.They can be downloaded at https://github.com/auroralab-unipr/PMT.

Motion planning
In the first set of experiments, we generated random trees with a number of nodes |V | ranging from 20 to 200 by 20 using the NetworkX (Hagberg et al., 2008) graph generator for random trees (function random tree()).The number of agents |P | ranges from 2 to |V |−2, while A s and A t are randomly generated.Only instances that fulfill Assumption (2) are taken into account.For every combination of number of nodes and number of agents, we generated 100 instances, each instance refers to a different graph.In Figure 12 we display the average number of moves of the solutions found on nc.According to Propositions 4.3 and 4.4, the motion planning algorithm returns solutions with length complexity O(nc).In Figure 12 we can see a linear upper bound for the average number of moves, that supports the complexity result.We can also see how the number of moves is often much lower than the upper bound found.We remark that instances with number of moves closer to the upper bound line are those for which the number of pebbles is very high (as expected, these are more tricky instances).

PMT
In the second set of experiments, we generated random trees with a number of nodes |V | ranging from 20 to 200 by 20 using the same procedure used for the first set of experiments.The number of agents |P | ranges from 5 to (3/4)|V | by 5, while A s and A t are randomly generated.As for the first set of experiments, only instances that fulfill Assumption (2) are taken into account.For every combination of number of nodes and number of agents, we generated 20 instances.In Figure 13 we display the average number of moves of the solutions found on n|P |c + n 2 .
As stated in Theorem 5.2, the length complexity of the PMT algorithm is O(n|P |c + n 2 ). Figure 13 displays a linear upper bound on the average number of moves, therefore confirming the complexity result.

Conclusion
In this paper we proposed two algorithms with improved length complexity for the motion planning problem and the pebble motion problem on trees.Denoting by n the number of nodes, c the maximum length of corridors and k the number of pebbles, the CATERPILLAR algorithm solves the motion planning problem with O(nc) moves, while the Leaves procedure solves the PMT problem in O(knc + n 2 ) moves.Moreover, we discuss a variant of the PMT problem, the PMT with trans-shipment vertices (ts-PMT), which considers a new type of vertex that cannot host pebbles.This problem is very interesting since MAPF instances on graphs can be reduced to it, and we proved that it can be solved with the Leaves procedure for PMT with some minor modifications.
As a topic for future research, we will study pebble motion, also known as Multi Agent Path Finding (MAPF), on general graphs.As already mentioned (see Section 6), the solution of MAPF on a general graph can be obtained by first converting it on the trans-shipment variant of PMT, and then converting back the obtained solution over the general graph.An upper bound for the solution length can be derived by exploiting the complexity results of this paper.

Figure 1 :
Figure 1: Example of Bring hole from w to v. Green squares represent pebbles, blue circles represent holes.

Figure 2 :
Figure 2: Example of Move Pebble from v to w. Green squares represent pebbles, blue circles represent holes.
b) Final configuration after moving holes c, d and g to T .

Figure 5 :
Figure 5: Example of execution of an iteration of the for cycle of Step 3 of Procedure A. Blue circles are holes, green squares are obstacles and the red square is the marked pebble.
Final configuration after Procedure B.

Figure 6 :
Figure 6: Example of situation of Case B with q = 4 missing holes.

Proposition 4. 4 .
The complexity of Procedure B is O(nc).

4.
Define tk = v and T k+1 = T v k .Set k = k + 1 and to go Step 2.

Figure 7 :
Figure 7: The four cases of Proposition 5.1.
4. CATERPILLAR algorithm.Each vertex is crossed O(c) times, indeed: (a) Procedure A. In Step 1 we solve a gather hole problem, therefore by point (2) each vertex is crossed O(c) times.In Step 3 each vertex that belongs to a caterpillar set S k is traversed once time by the pebble and once time by at most c obstacles that arrived from S k+1 and then moved to S k−1 .Therefore, in Procedure A each vertex is crossed O(c) times.

Figure 9 :
Figure 9: Conversion of a biconnected component of a graph into a star subgraph.
b) Final configuration after bringing the hole from w to v.

Figure 10 :
Figure 10: Example of Bring hole from w to v. Vertex u 3 is a trans-shipment.Green squares represent pebbles, blue circles represent holes.

Figure 12 :
Figure 12: Average number of moves for the algorithm motion planning on nc.

PMTFigure 13 :
Figure 13: Average number of moves for the algorithm PMT on n|P |c + n 2 .