Matchings under distance constraints I

This paper introduces the \emph{$d$-distance matching problem}, in which we are given a bipartite graph $G=(S,T;E)$ with $S=\{s_1,\dots,s_n\}$, a weight function on the edges and an integer $d\in\mathbb Z_+$. The goal is to find a maximum weight subset $M\subseteq E$ of the edges satisfying the following two conditions: i) the degree of every node of $S$ is at most one in $M$, ii) if $s_it,s_jt\in M$, then $|j-i|\geq d$. The question arises naturally, for example, in various scheduling problems. We show that the problem is NP-complete in general and admits a simple $3$-approxi\-mation. We give an FPT algorithm parameterized by $d$ and also settle the case when the size of $T$ is constant. From an approximability point of view, we show that the integrality gap of the natural integer programming model is at most $2-\frac{1}{2d-1}$, and give an LP-based approximation algorithm for the weighted case with the same guarantee. A combinatorial $(2-\frac{1}{d})$-approximation algorithm is also presented. Several greedy approaches are considered, in particular, a local search algorithm that achieves an approximation ratio of $3/2+\epsilon$ for any constant $\epsilon>0$ in the unweighted case. The novel approaches used in the analysis of the integrality gap and the approximation ratio of locally optimal solutions might be of independent combinatorial interest.


Introduction
In the perfect d-distance matching problem, one is given a bipartite graph G = (S, T ; E) with S = {s 1 , . . . , s n }, T = {t 1 , . . . , t k }, a weight function on the edges w : E → R + and an integer d ∈ Z + . The goal is to find a maximum-weight subset M ⊆ E of the edges such that the degree of every node of S is one in M and if s i t, s j t ∈ M , then |j − i| ≥ d. In the (non-perfect) d-distance matching problem, some of the nodes of S might remain uncovered. Note that the order of nodes in S = {s 1 , . . . , s n } affects the set of feasible d-distance matchings, but the order of T = {t 1 , . . . , t k } is indifferent. For example, Figure 1a is a feasible perfect 3-distance matching, but the example shown in Figure 1b is not, because edges s 1 t 2 and s 3 t 2 violate the 3-distance condition.
An application of this problem for w ≡ 1 is as follows. Imagine n consecutive all-day events s 1 , . . . , s n each of which must be assigned one of k watchmen t 1 , . . . , t k . For each event s i , a set of possible watchmen is given -those who are qualified to be on guard at event s i . Appoint exactly one watchman to each of the events such that no watchman is assigned to more than one of any d consecutive events, where d ∈ Z + is given. In the weighted version of the problem, let w sitj denote  the level of safety of event s i if watchman t j is on watch, and the objective is to maximize the level of overall safety. As another application of the above question, consider n items s 1 , . . . , s n one after another on a conveyor belt, and k machines t 1 , . . . , t k . Each item s i is to be processed on the conveyor belt by one of the qualified machines N (s i ) ⊆ {t 1 , . . . , t n } such that if a machine processes item s i , then it can not process the next d − 1 items -because the conveyor belt is running.
Motivated by the first application, in the cyclic d-distance matching problem the nodes of S are considered to be in cyclic order. The focus of this paper is on the above (perfect) d-distance matching problem, but some of the proposed approaches also apply for the cyclic case. In particular, the 3-approximation greedy algorithm achieves the same guarantee for the weighted cyclic case (see Section 3.3), and the (3/2 + ǫ)-approximation algorithm for the unweighted case (see Section 4.2).
Previous work Observe that in the special case d = |S|, one gets the classic (perfect) bipartite matching problem. For d = 1, the problem reduces to the b-matching problem, and one can show that it is a special case of the circulation problem for d = 2. This implies that the problem is solvable in strongly polynomial time for d = 1, 2, since the circulation problem can be solved in strongly polynomial time [13] and the b-matching problem is a special case of it.
A feasible d-distance matching M can be thought of as a b-matching that contains none of the subgraphs {({s i , s j }, {t}; {s i t, s j t}) : s i t, s j t ∈ E and |i − j| ≤ d}, where b s = 1 for s ∈ S and b t = |S| for t ∈ T . A similar problem is the K p,p -free p-matching problem [11]. Here one is given an arbitrary family T of the subgraphs of G isomorphic with K p,p , and the goal is to find a maximum-cardinality b-matching which induces no subgraph of T , where b : S ∪ T −→ {0, . . . , p}. This problem can be solved in polynomial time. Note that in the distance matching problem, b is different, and the type of the forbidden subgraphs is K 2,1 .
Another similar problem is the following. Given a partition E 1 , . . . , E k of E and positive integers r 1 , . . . , r k , find a perfect matching M for which |M ∩ E i | ≤ r i . The problem is introduced and shown to be NP-complete in [8]. Note that the side constraints in the distance matching problem are similar, but the degree constraints are different and our edge sets do not form a partition of E.
The perfect d-distance matching problem is a special case of the list-coloring problem on interval graphs [14]. Here a proper vertex coloring must be found for which the color of each node v is chosen from a predefined list of colors C v . Given an instance of the d-distance matching problem, we construct an interval graph H = (V, F ) such that there is a one-to-one correspondence between perfect d-distance matchings of G = (S, T ; E) and proper list colorings of H. Let the nodes of H be the intervals {R d (s) : s ∈ S}, where R d (s i ) = {s i , . . . , s min(i+d−1,|S|) } for i = 1, . . . , n, and let two distinct nodes R si , R sj ∈ V be connected by an edge if and only if R si ∩ R sj = ∅. Finally, let the list of possible colors of node R d (s i ) be the neighbors of s i in G. Observe that two nodes s i , s j ∈ S can be assigned to the same node of T in a distance matching M if and only if there is no edge between R d (s i ) and R d (s j ) in F . The latter holds, however, if and only if nodes R d (s i ) ∈ V and R d (s j ) ∈ V can be assigned color t simultaneously in a proper list coloring of H (note that t is in both lists of colors). Hence, there is a one-to-one correspondence between the perfect d-distance matchings of G and the proper list colorings of H.
The perfect d-distance matching problem is also a special case of the frequency assignment problem [1]. Let S = {s 1 , . . . , s n } be a set of antennas and let T = {t 1 , . . . , t k } be a set of frequencies.
There is an edge between s ∈ S and t ∈ T if antenna s can be set to frequency t. We are also given an interference graph of the antennas, in which two antennas are connected if and only if they may interfere with each other. The goal is to assign a frequency to each antenna such that no two interfering antennas are assigned the same (or in a certain sense similar, see [1]) frequency. To reduce the d-distance matching problem to the frequency assignment problem, let two antennas s i , s j interfere if and only if |i − j| ≤ d. This corresponds to the setting on the plane when antennas s 1 , . . . , s n are located along a straight line in this order such that the Euclidean distance between s i and s i+1 is one for i = 1, . . . , n − 1, and two antennas may interfere if and only if their Euclidean distance is at most d. By this construction, there exists a feasible frequency assignment (in which no two interfering antennas are assigned the same frequency) if and only if there exists a perfect d-distance matching.
Our results This paper settles the complexity of the distance matching problem and gives an FPT algorithm parameterized by d. An efficient algorithm for constant T is also given. We present an LPbased (2 − 1 2d−1 )-approximation algorithm for the weighted distance matching problem, which implies that the integrality gap of the natural IP model is at most 2− 1 2d−1 . An interesting alternative proof for the integrality gap is also given. We also describe a combinatorial (2 − 1 d )-approximation algorithm for the weighted case. One of the main contributions of the paper is a (3/2 + ǫ)-approximation algorithm for the unweighted case for any constant ǫ > 0 in the unweighted case. The proof is based on revealing the structure of locally optimal solutions recursively. A generalization of Kőnig's edge-coloring theorem [5,Page 74] is given to the distance matching problem, as well.
Notation Throughout the paper, assume that G = (S, T ; E) contains no loops or parallel edges, unless stated otherwise. Let ∆(v) and N (v) denote the set of incident edges to node v and the neighbors of v, respectively. For a subset X ⊆ E of the edges, N X (v) denotes the neighbors of v for edge set The maximum of the empty set is −∞ by definition. Given a function f : A → B, both f (a) and f a denote the value f assigns to a ∈ A, and let f (X) = a∈X f (a) for X ⊆ A. Let χ Z denote the characteristic vector of set Z, i.e. χ Z (y) = 1 if y ∈ Z, and 0 otherwise. Occasionally, the braces around sets consisting of a single element are omitted, e.g. χ e = χ {e} for e ∈ E.

Complexity
This section settles the complexity of the d-distance matching problem. First, we introduce the following NP-complete problem. Lemma 1. Given a bipartite graph G = (S, T ; E) and S 1 , S 2 ⊆ S such that S 1 ∪ S 2 = S, it is NPcomplete to decide if there exists M ⊆ E for which |M | = |S| and both M ∩ E 1 and M ∩ E 2 are matchings, where E i denotes the edges induced by T and S i for i = 1, 2. The problem remains NPcomplete even if the maximum degree of the graph is at most 4.
Proof. We reduce the 3-Dimensional Matching problem to the problem defined in the lemma statement. Here, one is given three finite disjoint sets X, Y, Z and a set of hyperedges H ⊆ X × Y × Z. A subset of the hyperedges F ⊆ H is called 3-dimensional matching if x 1 = x 2 , y 1 = y 2 and z 1 = z 2 for any two distinct triples (x 1 , y 1 , z 1 ), (x 2 , y 2 , z 2 ) ∈ F . Being one of Karp's 21 NP-complete problems [9], it is NP-complete to decide whether there exists a 3-dimensional matching F ⊆ H of size |Z|. In fact, the problem remains NP-complete even if no element of X ∪ Y ∪ Z occurs in more than three triples in H [7, Page 221]. Without loss of generality, one might assume that |X| = |Y | = |Z|. Let H z = {e z 1 , . . . , e z kz } denote the set of hyperedges incident to z ∈ Z, i.e.
(a) An instance of the 3dimensional matching problem.  for each z ∈ Z. To reduce the 3-dimensional matching problem to the above problem, consider the following construction. First define a bipartite graph G = (S, T ; E) where S = X ∪ (H \ {e z 1 : z ∈ Z}) ∪ Y , T = H and E is as follows. For each s ∈ S ∩ (X ∪ Y ), add an edge between s and all the hyperedges e ∈ T incident to s; and connect each e z i ∈ S ∩ H to hyperedges e z i−1 , e z i ∈ T for each z ∈ Z and i = 2, . . . , k z . Let S 1 = S \ Y and S 2 = S \ X. Figure 2a and 2b show an instance of the 3-dimensional matching problem and the corresponding construction, respectively. Each hyperedge is represented by a unique line style, e.g. the dotted lines represent hyperedge e 1 = (x 2 , y 1 , z 1 ) in Figure 2a, and the dotted lines correspond to the same hyperedge e 1 in Figure 2b. Note that the edges represented by a straight line in Figure 2b do not represent hyperedges, but the edges between hyperedges. The highlighted edges in Figure 2a and 2b correspond to the same feasible 3-dimensional matching.
Observe that there exists a 3-dimensional matching F of size |Z| if and only if there exists M ⊆ E for which |M | = |S| and both M ∩ E 1 and M ∩ E 2 are matchings, where E i denotes the edges incident to S i (i = 1, 2). Indeed, such an M ⊆ E matches all nodes of S into T , therefore there exists a unique hyperedge e * z ∈ T ∩ H z for each z ∈ Z that is not matched to S ∩ H, but to exactly one element of x ∈ X and exactly one element of y ∈ Y (because all hyperedges in S ∩ H z are matched into T ∩ H z , and these edges of M cover all but one hyperedge of T ∩ H z ). These three edges correspond to the inclusion of hyperedge (x, y, z). This way one obtains a 3-dimensional matching F of size |Z|. On the other hand, if a 3-dimensional matching F is given for which |F | = |Z|, then one might easily construct the desired M ⊆ E as follows. For each (x, y, z) ∈ F , let i be the unique index such that e z i = (x, y, z) ∈ F and extend M with edges xe z i , ye z i ∈ E. Let us also include a perfect matching between S ∩ H z and (T ∩ H z ) \ {e z i } (such a perfect matching exists, because the induced subgraph consists of at most two disjoint paths of odd length). It is easy to see that |M | = |S| and both M ∩ E 1 and M ∩ E 2 are matchings, and hence M is feasible.
To complete the proof, observe that the maximum degree in G is at most four if one starts with an instance of the 3-dimensional matching for which no element of X ∪ Y ∪ Z occurs in more than three triples. Hence, the problem indeed remains NP-complete even if the maximum degree is 4.
In what follows, the previous problem is reduced to the d-distance matching problem, hence the hardness of the latter.
Theorem 2. It is NP-complete to decide if a graph has a perfect d-distance matching, even if the maximum degree of the graph is at most 4.  Figure 2b has a feasible solution of size 9.
Proof. It suffices to reduce the problem from Lemma 1 to the perfect d-distance matching problem. Let G = (S, T ; E); S 1 , S 2 ⊆ S, S 1 ∪S 2 = S be an instance of the above problem. Without loss of generality, one might assume that S 1 ⊆ S 2 and S 2 ⊆ S 1 . To construct an instance G ′ = (S ′ , T ′ ; E ′ ), d ∈ N of the perfect d-distance matching problem, let G ′ = G and modify G ′ as follows. Order the nodes of S ′ such that the nodes of S 1 \ S 2 , S 1 ∩ S 2 and S 2 \ S 1 appear in this order (the order of the elements inside the three sets is arbitrary). Insert |S 1 \ S 2 | and |S 2 \ S 1 | new nodes to S ′ right after the last node of S 1 and right before the first node covered by S 2 , respectively. Finally, add |S 1 \ S 2 | + |S 2 \ S 1 | new nodes to T ′ , extend E ′ with the edges of a perfect matching between the newly added nodes and let d = |S|. Figure 3 illustrates the construction. The blank nodes on the figure are the newly inserted ones, and S ′ i is the union of S i and the i th set of new nodes added to S ′ . The highlighted edges correspond to those in Figure 2b.
To complete the proof, observe that there exists a perfect |S|-distance matching in G ′ if and only if there exists M ⊆ E for which |M | = |S| and both M ∩ E 1 and M ∩ E 2 are matchings. Indeed, from M one obtains a perfect |S|-distance matching in G ′ by simply adding the perfect matching between the new nodes. To see the other direction, one has to remove this perfect matching from the perfect S-distance matching. Note that the maximum degree in G ′ is not larger than in G, hence the problem remains hard even if the maximum degree is at most 4.

Weighted d-distance matching problem
This section presents various approaches to the weighted d-distance matching problem. Section 3.1 presents an FPT algorithm [4] parameterized by d, while Section 3.2 settles the case when the size of T is constant. A simple greedy approach is presented in Section 3.3. Finally, Sections 3.4.1 and 3.4.2 are devoted to the investigation of the natural linear programming model.

FPT algorithm parameterized by d
In what follows, an FPT algorithm parameterized by d is presented for the weighted (perfect) ddistance matching problem. Observe that the weighted d-distance matching problem easily reduces to the perfect case by adding a new node t s to T and a new edge st s of weight zero for each s ∈ S, therefore the algorithm is given only for the weighted perfect d-distance matching problem. The next claim gives a way to reduce the problem so that it admits an efficient dynamic programming solution.
Claim 3. Suppose that s ∈ S is such that deg(s) ≥ 2d. Then, we can remove an arbitrary minimumweight edge of ∆(s) from the edge set without changing the weight of the optimal perfect d-distance matching.
Proof. Let st be a minimum-weight edge incident to node s. In order to prove that st can be removed, it suffices to show that there is a maximum-weight d-distance matching that does not use edge st. Given a d-distance matching M that contains edge st, let Z ⊆ T denote the nodes that M assigns to Based on this claim, the problem can be reduced so that the degree of each node s ∈ S is at most 2d − 1. The reduction can be performed in O(m + n) steps by removing all but the 2d − 1 heaviest edges incident to each node s ∈ S. To this end, let us assume that each edge weight occurs only once (otherwise fix an arbitrary order between the ties), and for each s ∈ S, find the (2d − 1) th lightest edge e s in ∆(s) with the linear time selection algorithm, and then eliminate all edges of ∆(s) which are lighter than e s .
In what follows, a dynamic programming approach is presented to solve the reduced problem in . . , z d ) denote the weight of the maximum-weight perfect d-distance matching if the problem is restricted to the first i nodes of S and s i−j+1 is assigned to its neighbor z j for where i ≥ d, s i ∈ S, z j ∈ N (s i−j+1 ) for j = 1, . . . , d and z 1 , . . . , z d are distinct. To see that recursion (1) holds, observe that in its first case, by definition, f (s d , z 1 , . . . , z d ) is the weight of matching {s j z d−j+1 : j = 1, . . . , d}. In the second case of (1), s i must be mapped to z 1 , and we want to find the maximum-weight perfect d-distance matching on the first i − 1 nodes of S which maps s i−j+1 to its neighbor z j for j = 2, . . . , d. To this end, we want to find a node t ∈ N (s i−d ) (to be assigned to node s i−d ) which maximizes f (s i−1 , z 2 , . . . , z d , t). By definition, the weight of the optimal d-distance matching is max{f (s n , z 1 , . . . , z d ) : z j ∈ N (s n−j+1 ) for j = 1, . . . , d}.
Observe that the number of subproblems is O(n(2d − 1) d ), since the degree of each s ∈ S is at most 2d − 1. Recursion (1) gives a way to compute f (s i , z 1 , . . . , z d ) in O(d) steps if the subproblems are computed in appropriate order, i.e. the value f ( Therefore the number of steps to compute all the subproblems is O(dn(2d − 1) d ). Furthermore, the optimum value can be computed in O((2d − 1) d ) steps by (2). The overall running time of the algorithm is O(dn(2d − 1) d + poly(|S| + |T |)).

Remark 4.
To improve the running time to O(nd d+1 + poly(|S| + |T |)), observe that when is computed in (1), we need to consider only the (at most) d heaviest edges of ∆(s i−d ) which are not incident to any of z 2 , . . . , z d ∈ T , since we only need to make sure that there is no conflict with the d − 1 nodes on the left of s i−d . This way the number of subproblems is O(nd d ), and the overall number of steps is O(nd d+1 + poly(|S| + |T |)). Similarly, in (2) one needs to consider only the d heaviest edges incident to z j which are not incident to any of z j+1 , . . . , z d , therefore there are at most d d different configurations to be taken into account in (2).

Efficient algorithm for constant |T |
If the size of T is constant, then one can solve the problem efficiently as well. First, consider the following subproblems. Let f (s i , d 1 , . . . , d |T | ) denote the weight of the optimal perfect d-distance matching when the problem is restricted to s 1 , . . . , s i , and t j cannot be matched to nodes s i−dj +1 , . . . , s i for j = 1, . . . , |T | (here d j = 0 means that t j can be matched to any node). Formally, f (s i , d 1 , . . . , d |T | ) can be defined as follows. If i ≥ 2, then let By definition, the weight of the optimal d-distance matching is given by The number of subproblems to be solved is O(nd |T | ), each of which can be computed in O(|T |) steps by (3) and (4). Once all the subproblems are computed, it takes additional O(|T |) steps to compute the optimal value by (5). Hence the overall number of steps is O(n|T |d |T | ).
A similar approach settles the non-perfect case for constant |T |, the details of which are left to the reader.

A greedy algorithm
This section describes a greedy method for the weighted (not-necessarily-perfect) d-distance matching problem, and proves that it is a 3-approximation algorithm.

Algorithm 1
Greedy Let e 1 , . . . , e m be the edges in non-increasing order by their weights.
Greedy is a 3-approximation algorithm for the weighted d-distance matching problem.
Proof. Assume that Greedy returns edges f 1 , . . . , f p , and it selects them in this order. Let M i denote a maximum-weight d-distance matching that contains Furthermore, let θ i denote the weight of M i for i = 0, . . . , p. Note that θ 0 is the weight of the optimal d-distance matching and θ p is the weight of the matching Greedy returns. Observe that there exist edges e, e ′ , e ′′ ∈ M i \ {f 1 , . . . , which contains edges f 1 , . . . , f i+1 . By the greedy selection rule, w e , w e ′ , w e ′′ ≤ w fi+1 , one gets holds for all i = 0, . . . , p − 1. A simple inductive argument shows that (6) w fi , therefore 3θ p ≥ θ 0 follows, which completes the proof. The analysis is tight even for d = 2 and w ≡ 1 in the sense that Greedy might return only one edge, while the largest 2-distance matching consists of 3 edges, see Figure 4a for an example.   Remark 6. The above proof shows that Greedy is a 3-approximation algorithm for the more general cyclic d-distance matching problem, in which the nodes of S are considered in cyclic order.

Linear programming
The following two sections prove that the integrality gap of the natural integer programming model is at most 2 − 1 2d−1 , and present an LP-based (2 − 1 2d−1 )-approximation algorithm for the weighted d-distance matching problem. First consider the relaxation of the natural 0 − 1 integer programming formulation of the weighted d-distance matching problem.
One gets the relaxation of the 0 − 1 integer programming formulation (LP2) of the weighted perfect d-distance matching problem by tightening (7b) to equality in LP1.

Integrality gap
This section proves that the integrality gap of LP1 is at most 2 − 1 2d−1 , and proves the integrality of LP1 and LP2 in special cases. The former result also follows from the LP-based approximation algorithm described in Section 3.4.2. The following definition plays a central role both in the analysis of the integrality gap and in the LP-based approximation algorithm presented in the next section.
That is, an order of the edges is θ-flat if the sum of x on those edges among e i+1 , . . . , e m that are hit by an edge e i is at most θ − x ei for every i. Note that any order of the edges is 3-flat by definition, since for any edge e = st, the sum of variables on all edges incident to s is at most 1 by (7b), whereas the sum on the edges induced by L d (s) ∪ R d (s) and {t} is at most 2 by (7c). The following lemma further improves this bound to 2 − 1 2d−1 .

Lemma 8.
There exists an optimal solution x ∈ Q E of LP1 and an order e 1 = s 1 t 1 , . . . , e m = s m t m of the edges that is (2 − 1 2d−1 )-flat with respect to x. Proof. Let E s ⊆ ∆(s) denote the first min(2d − 1, deg(s)) largest weight edges incident to node s for each s ∈ S. Let x be an optimal solution to LP1 for which γ(x) = {x e : e ∈ E \ s∈S E s } is minimal. Towards a contradiction, suppose that γ(x) > 0. By definition, γ(x) > 0 implies that there exists an which is not possible because of the constraints (7b). But then wx ≤ wx ′ and γ(x ′ ) < γ(x), contradicting the minimality of γ(x). Therefore γ(x) = 0 follows, meaning that x e = 0 holds for each e ∈ E \ s∈S E s . Hence one can restrict the edge set to s∈S E s without change in the optimal objective value, which implies that there exists a rational optimal solution x ∈ Q E of LP1 with γ(x) = 0.
Let x be as above, and let e 1 = s 1 t 1 , . . . , e m = s m t m be the order of the edges given by Algorithm 2 for input x. To prove that this order is (2 − 1 2d−1 )-flat with respect to x, let ξ i andξ i (i = 1, . . . , n) be as in Definition 7. First observe thatξ i ≤ 1 − x i holds for each i = 1, . . . , n, because the algorithm places each edge i−1 j=1 ∆(s j ) before e i . Hence, to obtain (8), it suffices to prove that ξ i ≤ 1− 1 2d−1 . For any node s ∈ S, if there exists an edge st ∈ ∆(s) for which x st ≥ 1 2d−1 , then ξ i ≤ 1 − 1 2d−1 follows for each e i ∈ ∆(s), since x e ≥ 1 2d−1 holds for the first edge e ∈ ∆(s) selected by Algorithm 2. Otherwise, there exists no edge st ∈ ∆(s) for which x st ≥ 1 2d−1 . Therefore ξ i ≤ x(∆(s)) < |E s | 1 2d−1 ≤ 1 follows for e i ∈ ∆(s), which completes the proof if |E i | < 2d − 1. Hence one can assume that |E i | = 2d − 1. Next we argue that x ′ = x + ǫχ st ′ is feasible for some st ′ ∈ E s and sufficiently small ǫ > 0. By contradiction, if there existed no such edge st ′ , then it is one of the constraints (7c) that  Figure 5: For w ≡ 1 and d = 5, x ≡ 1/2 is an optimal solution to LP1, and the highlighted edges form an optimal 5-distance matching, hence the integrality gap is 6 /5.
Proof. Let θ = 2 − 1 2d−1 . By Lemma 8, there exists a solution x ∈ Q E to LP1 and an order of the edges e 1 = s 1 t 1 , . . . , e m = s m t m that is θ-flat with respect to x. First, it will be shown that there exist d-distance matchings M 1 , . . . , M q and coefficients λ 1 , . . . , λ q ∈ Q + such that Let K ∈ N be the lowest common denominator of {x e : e ∈ E}, and let q = ⌊Kθ⌋. The main observation is that each edge e ∈ E can be assigned a set of colors C e ⊆ {1, . . . , q} such that each color class corresponds to a feasible d-distance matching and |C e | = Kx e . To prove this, the edges are greedily colored one by one in order e m , . . . , e 1 . By induction, assume that edges e m , . . . , e i+1 already have their color sets. It suffices to assign a color set C ei to edge e i which is of size Kx ei and distinct from both A := {C ej : j > i, e j ∈ ∆(s i )} and B := Without loss of generality, assume that x ei > 0 (otherwise C ei = ∅). By (8), one gets |A ∪ B| ≤ |A| + |B| = K(ξ i +ξ i ) ≤ ⌊K(θ − x ei )⌋ = ⌊Kθ⌋ − Kx ei = q − Kx ei , thus |A ∪ B| + Kx ei ≤ q. That is, the number of free colors is at least Kx ei , so let C ei be any Kx ei colors in {1, . . . , q} \ (A ∪ B).
Let the desired d-distance matching M i consist of the edges with color i for i = 1, . . . , q. Set λ i = 1 K for all i = 1, . . . , q, and observe that both Now, we are ready to argue that there exists a λ-approximate solution among M 1 , . . . , M q . By contradiction, suppose that λw(M i ) < w(M * ) for each i = 1, . . . , q, where M * is an optimal distance matching. Observe that w , that is, the LP optimum is strictly smaller than the IP optimum, which is a contradiction. Therefore, the largest weight d-distance matchings among M 1 , . . . , M q are indeed λ-approximate. Since λ = q i=1 λ i ≤ 2 − 1 2d−1 , the proof is complete. Note that the above approach is algorithmic, but it does not necessarily run in polynomial time -since q may be exponential in the size of the graph. The next section presents a polynomial-time method and re-proves that the integrality gap is at most 2 − 1 2d−1 . Remark 10. Figure 5 provides an example with (the largest known) integrality gap 6/5. Using this instance, one might easily derive an example (by adding two new nodes t 5 and t 6 to T , and two new edges s 3 t 5 , s 6 t 6 ) for which no perfect 5-distance matching exists, but there is a fractional perfect 5distance matching -meaning that the integrality gap of LP2 is unbounded as it was expected due to the complexity of the problem.
In what follows, the integrality of LP1 and LP2 are shown in special cases.
Proof. For d = 1, the matrix of LP1 and LP2 is the incidence matrix of a bipartite graph, which is a well-known network matrix [5,Page 149]. For d = 2, one can easily construct a directed graph and a spanning tree (in this case a directed caterpillar) for which the corresponding network matrix is the matrix of LP1 and LP2. As the right-hand side of both programs are integral and their matrices are network matrices (and hence totally unimodular) for d = 1, 2, the proof is complete. Note that the statement for d = 1 also follows from Theorem 9.
Note that the matrix of LP1 and LP2 is not totally unimodular for d ≥ 3 if the input graph is the complete bipartite graph -the technical proof is omitted here. Therefore, the proof of Theorem 11 can not work for d ≥ 3 and one can not expect that LP1 and LP2 remain integral. Having said that, LP2 still describes the convex hull of the integral solutions for d = |T |, but not because of total unimodularity: Proof. Let A denote the matrix of LP2, and letx be an optimal integral solution. Ifx is not an optimal LP solution, then there is no complementary dual solution y, therefore -by Farkas' lemma -there exists z ∈ R E for which Let z j = (z s1tj , z s2tj , . . . , z s |S| tj ). Observe that z j i = z j k for all j = 1, . . . , d whenever i ≡ k mod d, which allows the simplification of (9a)-(9d). For all i = 1, . . . , d and j = 1, . . . , |T |, letẑ j i be a new variable representing all variables {z j i ′ : i ≡ i ′ mod d}, and consider the following formulation.
, . . . , |S|} and i ′ ≡ i mod d}. Note that system (9a)-(9d) has a feasible solution if and only if (10a)-(10e) has one with positive objective value. As the optimal value of (10a)-(10e) is finite and its matrix is totally unimodular (the incidence matrix of a bipartite graph and identity matrices under it), there is an integral solutionẑ * to (10a)-(10e) with a positive objective value. This particular solution corresponds to an integral solution z * to (9a)-(9d) with the same positive weight. But this means thatx + z * is an integral solution of LP2, for which wx < w(x + z * ) holds, contradicting the fact thatx was an optimal integral solution.
Note that the analogous statement for LP1 does not hold.

Algorithm 3
θ-approximation algorithm for the weighted distance matching problem Let e 1 , . . . , e m be a θ-flat order with respect to a solution x of LP1 (see Lemma 8).
Let st be the first edge according to the above order that appears in E.
2d−1 )-approximation algorithm for the weighted d-distance matching This section presents an "almost greedy" LP-based (2 − 1 2d−1 )-approximation algorithm and re-proves that the integrality gap is at most θ := 2 − 1 2d−1 . Theorem 13. Algorithm 3 is a θ-approximation algorithm for the weighted d-distance matching problem if a θ-flat order of the edges is given in the first step of the algorithm.
Proof. The proof is by induction on the number of edges. Let M denote the distance matching found by WdmLpApx(E,w), and let x be as defined in Algorithm 3. In the base case, if E = ∅, then θw(M ) ≥ wx holds. Let st ∈ E be the first edge with respect to the order of the edges used by Algorithm 3. By induction, The key observation is that follows from the definition of w ′ and the order of the edges. Hence, one gets where w ′ (M ) = w ′ (M ′ ) because w ′ st = 0. Therefore, M is indeed a θ-approximate solution, which completes the proof.
Theorem 13 also implies that the integrality gap of LP1 is at most θ. Note that if we have a θ ′ -flat order of the edges in the first step of Algorithm 3, then it outputs a θ ′ -approximate solution. We believe that there always exists a θ ′ -flat order of the edges for some θ ′ < θ, i.e. it is possible to improve Lemma 8, which would automatically improve both the integrality gap and the approximation guarantee of the algorithm to θ ′ .

A combinatorial (2 − 1 d )-approximation algorithm
This section presents a (2 − 1 d )-approximation algorithm for the weighted distance matching problem. Let k ∈ {d − 1, . . . , 3d − 3} be such that 2d − 1 divides |S| + k, and add k new dummy nodes s n+1 , . . . , s n+k to the end of S in this order. Let us consider the extended node set in cyclic order. Observe that the new cyclic problem is equivalent to the original one. Let H j denote the subgraph of G induced by R d (s j ) ∪ T , where R d (s j ) is the set consisting of node s j and the next d − 1 nodes Since M i * can be computed in strongly polynomial time, we obtain a strongly-polynomial-time (2 − 1 d )-approximation algorithm by the following theorem.
Each node of S is covered by at most one edge of M i , as M i is the union of matchings no two of which cover the same node of S. If s i t, s j t ∈ M i , then s i t and s j t belong to two distinct matchings F k , F l ⊆ M i for some k, l, hence |j − i| ≥ d. From this, the feasibility of M i follows for all i = 1, . . . , 2d − 1, and M i * being one of them, it is feasible as well.
To show the approximation guarantee, let M * be an optimal d-distance matching. For each node s ∈ S, let µ s ∈ R + denote the weight of the edge covering s in M * and zero if M * does not cover s. Note that s∈S µ s = w(M * ) by definition, and s∈Si µ s ≤ w(M i ) (13) follows because s∈Si µ s is the weight of a d-distance matching which covers no nodes outside G i . Observe that holds, where the second equation holds because µ s occurs d times as a summand in s∈Si µ s for all s ∈ S, the first inequality follows from (13), while the last one holds because M i * is a largestweight d-distance matching among M 1 , . . . , M 2d−1 . By (14), one gets w(M * ) ≤ (2 − 1 d )w(M i * ), which completes the proof of the theorem.
The analysis is tight in the sense that, for every d ∈ Z + , there exists a graph G for which the algorithm returns a d-distance matching M for which w(M * ) = (2 − 1 d )w(M ), where M * is an optimal d-distance matching. Let S and T consist of 2d − 1 and d nodes, respectively. Add edge s i t i for i = 1, . . . , d, and edge s i+d t i for i = 1, . . . , d − 1. Note that the edge set is a feasible d-distance matching itself, and the above algorithm returns a matching that covers exactly d nodes of S. Hence the approximation ratio of the found solution is 2d−1 d . Figure 6 shows the construction for d = 3, where s 6 , . . . , s 10 are the dummy nodes.

Unweighted d-distance matching
First, two refined greedy approaches are considered for the unweighted case, then the analysis of the approximation ratio of locally optimal solutions follows.

Greedy algorithms
This section describes two refined greedy algorithms for the unweighted d-distance matching problem, and proves that both of them achieve an approximation guarantee of 2.
holds for all i = 0, . . . , p−1. A straightforward inductive argument shows that (15) implies θ p ≥ θ 0 −p, therefore 2θ p ≥ θ 0 follows, which completes the proof. The analysis is tight in the sense that S-Greedy might return only one edge, while the largest 2-distance matching consists of 2 edges, see Figure 4b.

T -Greedy
Let s 1 , . . . , s n be the nodes of S in the given order M := ∅ C := ∅ for j = 1, . . . , k do Observe that M S covers node s i , otherwise S-Greedy could have included edge s i s t . Therefore, S-Greedy assigns node s i to t j ′ , where j ′ = j. Similarly to the argument in Case 1, it is easy to see that neither j ′ < j nor j ′ > j is possible. Figure 4b shows that the approximation ratio is tight.

Local search
This section investigates the approximation ratio of the so-called locally optimal solutions. First, consider the following notion, which plays a central role throughout the section. We say that an edge e * hits the edges of H(e * , M ), or that H(e * , M ) is the hit set of edge e * with respect to M . Similar notation and terminology are used for a subset of the edges as follows. Claim 20. A d-distance matching M is 1-locally optimal if and only if there exists a permutation of E such that Greedy outputs M for w ≡ 1.
Proof. If M is the output of Greedy, then there exists no edge e outside M which can be added to M (otherwise Greedy could have added e when it tried to), hence M is 1-locally optimal by definition. On the other hand, if M is 1-locally optimal, then permute E such that the edges of M come first. As w ≡ 1, one can choose this particular permutation in the first line of Algorithm 1. To complete the proof, observe that its output is M itself, since it includes all edges of M as M is feasible, and may not include any other edges, because M is 1-locally optimal.
In what follows, an upper bound ̺ l is shown on the approximation ratio of l-locally optimal solutions for each l ≥ 1, where ̺ l is defined by the following recursion.
For l = 1, 2, 3, 4, the statement can be proved by a simple argument, given below. However, this approach does not seem to work in the general case. The proof of the general case, which is much more involved and quite esoteric, is given after the following theorem.
Consider the following extension of Definition 17.
Definition 25. Given an (R, d)-distance matching M and an edge sv ∈ (S × T ) ∪ R, let In other words, each st ∈ E hits the edges hit by H(st, M ) and all the loops incident to node s, while each loop hits only itself. A natural way to define the hit set of multiple edges is as follows.
Using H + , the definition of l-locally optimal d-distance matchings can be naturally extended to (R, d)-distance matchings.
Note that each of these definitions reduces to its original counterpart if R = ∅. Therefore, it suffices to show that ̺ l is an upper bound on the approximation ratio of (R, l)-locally optimal solutions.
To elaborate on the intuition behind these technical definitions and to understand how R influences locally optimality, suppose that we are given a feasible d-distance matching M , which we want to make l-locally optimal. To this end, one needs to find a d-distance matching X ⊆ E \ M of cardinality at most l that hits strictly fewer edges of M then its cardinality. In an (R, d)-distance matching, however, the number of edges hit by such a subset X can be larger because of the loops (as H + (X, M ) also counts those), meaning that the requirements for l-locally optimality are relaxed. Intuitively, the loops incident to a node s ∈ S can be thought of as the "resistances" of s: the more loops s has, the less we want to replace the edge of M incident to s with some other edge of ∆(s). Note, however, that the loops also contribute to the size of the matching, which will be crucial in the proof of the next theorem.
Theorem 28. If M, M * are (R, d)-distance matchings such that M is l-locally optimal with respect to M * , then the approximation ratio |M * | /|M| is at most ̺ l , where l ≥ 1 and ̺ l is as defined above.
The proof is by induction on l. The argument for l = 1, 2 is analogous to that in the proof of Theorem 21. Case 1: l = 1. It easily follows from (25) that Case 2: l = 2. Similarly, where the second inequality follows from (25) and the third one holds because M is 2-locally optimal with respect to M * . Case 3: l ≥ 3. One has to show that |M * | /|M| ≤ 4̺ l−2 − 3 /2̺ l−2 − 1. First, introduce the notation α(M, M * ) = s 1 s 2 s 3 s 4 t 1 t 2 Figure 7: The wavy edges form a 2-locally optimal 2-distance matching M , and M * = E \ M is the optimal 2-distance matching. The approximation ratio |M * | /|M| is ̺ 2 = 2.
where the second inequality holds by the following computation.  (30) and (31), one obtains that |H + (M * , M )| < |M * | ≤ l, which contradicts that M is l-locally optimal with respect to M * . Hence -in contrast to the indirect assumption -condition 5) holds, and this proves the lemma.
Note that if R = ∅, then Lemma 29 gives back (20) and (22) for l = 3, 4, respectively. By Lemma 29, inequality (28) follows, meaning that the desired recursion (16) gives a valid upper bound on the approximation ratio of the l-locally optimal solutions.
Corollary 30. The approximation ratio of l-locally optimal d-distance matchings is at most ̺ l , where ̺ l is as defined above.
Proof. Let M * denote an optimal d-distance matching. By definition, M is l-locally optimal with respect to M * , therefore M is (∅, l)-locally optimal with respect to M * . By Theorem 28, one gets |M * | /|M| ≤ ̺ l , which completes the proof.
Corollary 31. For any constant ǫ > 0, there exist a polynomial-time algorithm for the unweighted d-distance matching problem that achieves an approximation guarantee of 3/2 + ǫ.
Proof. By Corollary 30, the approximation ratio of l-locally optimal solutions is at most ̺ l . One might easily show that lim l→∞ ̺ l = 3/2. Hence for any ǫ > 0, there exists l 0 ∈ N such that ̺ l ≤ 3/2 + ǫ. To complete the proof, observe that l 0 is independent from the problem size, therefore one can compute an l 0 -locally optimal solution in polynomial time. Note that the number of improvements is at most the size of the matching and hence it is polynomial as well.
Remark 32. Figure 4a, 7 and 8 show that the upper bound on the approximation ratio of l-locally optimal solutions given by Theorem 28 is tight for l = 1, 2 and 3, respectively. It remains open whether the analysis is tight for l ≥ 4.
Remark 33. Similar proof shows that for any constant ǫ > 0, the above local-search algorithm is a (3/2 + ǫ)-approximation algorithm for the unweighted cyclic d-distance matching problem. s 1 s 2 s 3 s 4 s 5 s 6 s 7 s 8 s 9 s 10 s 11 s 12 s 13 s 14 s 15 s 16 s 17 s 18 t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 Figure 8: The wavy edges form a 3-locally optimal 5-distance matching M , and M * = E \ M is the optimal 5-distance matching. The approximation ratio |M * | /|M| is ̺ 3 = 9 /5.

Regular distance matching
The following theorem is a straightforward generalization of the well-known result that every regular bipartite graph has a perfect matching.
Definition 34. An instance of the d-distance matching problem is r-regular if deg(s) = r for each s ∈ S and the number of edges between t and R d (s i ) is r for each t ∈ T and i = 1, . . . , n − d + 1.
Theorem 35. If a problem instance is r-regular, then there exists a perfect d-distance matching.
Proof. There exists a perfect matching between {s 1 , . . . , s d } and T , because the induced graph is rregular. By induction, assume that the degrees of {s 1 , . . . , s i−1 } in M are one, where i − 1 ≥ d. Let t denote the node that M assigns to s i−d+1 . If s i t ∈ E, then the number of edges between t and L d (s i ) is r − 1, meaning that the instance at hand is not r-regular, hence s i t ∈ E. Therefore, M ∪ {s i t} is feasible for the first i nodes of S, hence the claim follows.
If we leave out a perfect d-distance matching from an r-regular problem instance, then it becomes an r − 1 regular instance, hence one gets the following generalization of Kőnig's edge-coloring theorem [5, Page 74].
Corollary 36. If a problem instance is r-regular, then the edge set of the graph partitions into r perfect d-distance matchings.

Conclusion
This paper introduced the d-distance matching problem. We proved that the problem is NP-complete in general and admits a 3-approximation. We gave an FPT algorithm parameterized by d and also settled the case when the size of T is constant. The integrality gap of the natural integer programming model is shown to be at most 2− 1 2d−1 , and an LP-based approximation algorithm for the weighted case is given with the same guarantee. Using a different approach, a combinatorial (2 − 1 d )-approximation algorithm was also described. Several greedy approaches, including a local search algorithm, were presented. The latter method achieves an approximation ratio of 3/2 + ǫ for any constant ǫ > 0 in the unweighted case.
The problem itself has several generalizations (e.g. pose degree bounds on the nodes of both S and T , cyclic version of the problem, distance-constraints on both node classes, etc.), which are subjects for further research.
comments that greatly improved an earlier version of the manuscript. The author is indebted to the anonymous reviewers of an earlier version of the manuscript for their valuable comments and suggestions.