Linear-Time Algorithms for Maximum-Weight Induced Matchings and Minimum Chain Covers in Convex Bipartite Graphs

A bipartite graph $G=(U,V,E)$ is convex if the vertices in $V$ can be linearly ordered such that for each vertex $u\in U$, the neighbors of $u$ are consecutive in the ordering of $V$. An induced matching $H$ of $G$ is a matching such that no edge of $E$ connects endpoints of two different edges of $H$. We show that in a convex bipartite graph with $n$ vertices and $m$ weighted edges, an induced matching of maximum total weight can be computed in $O(n+m)$ time. An unweighted convex bipartite graph has a representation of size $O(n)$ that records for each vertex $u\in U$ the first and last neighbor in the ordering of $V$. Given such a compact representation, we compute an induced matching of maximum cardinality in $O(n)$ time. In convex bipartite graphs, maximum-cardinality induced matchings are dual to minimum chain covers. A chain cover is a covering of the edge set by chain subgraphs, that is, subgraphs that do not contain induced matchings of more than one edge. Given a compact representation, we compute a representation of a minimum chain cover in $O(n)$ time. If no compact representation is given, the cover can be computed in $O(n+m)$ time. All of our algorithms achieve optimal running time for the respective problem and model. Previous algorithms considered only the unweighted case, and the best algorithm for computing a maximum-cardinality induced matching or a minimum chain cover in a convex bipartite graph had a running time of $O(n^2)$.


Introduction
Problem Statement. A bipartite graph G = (U, V, E) is convex if V can be numbered as {1, 2, . . . , n V } so that the neighbors of every vertex i ∈ U form an interval {L i , L i + 1, . . . , R i }, see Figure 1(a). For such graphs, we consider the problem of computing an induced matching (a) of maximum cardinality or (b) of maximum total weight, for graphs with edge weights.
An induced matching H ⊆ E is a matching that results as a subgraph induced by some subset of vertices. This amounts to requiring that no edge of E connects endpoints of two different edges of H, see Figure 1(a). In terms of the line graph, an induced matching is an independent set in the square of the line graph. The square of a graph connects every pair of nodes whose distance is one or two. Accordingly, we call two edges of E independent if they can appear together in an induced matching, or in other words, if their endpoints induce a 2K 2 (a disjoint union of two edges) in G. Otherwise, they are called dependent.
In convex bipartite graphs, maximum-cardinality induced matchings are dual to minimum chain covers. A chain graph Z is a bipartite graph that contains no induced matching of more than one edge, i. e., it contains no pair of independent edges. (Chain graphs are also called difference graphs [12] or non-separable bipartite graphs [7].) A chain cover of a graph G with edge set E is a set of chain subgraphs Z 1 , Z 2 , . . . , Z W of G such that the union of the edge sets of Z 1 , Z 2 , . . . , Z W is E, see Figure 1 Since we use successive natural numbers as elements of U and V , we will explicitly indicate whether we regard a number x as a vertex of U or of V . There is no induced matching with more than 3 edges: vertex 3 ∈ U is adjacent to all vertices of V except 1 ∈ V . Thus, if we match 3 ∈ U , this can only lead to induced matchings of size at most 2. Furthermore, we cannot simultaneously match 1 ∈ U and 2 ∈ U since every neighbor of 2 ∈ U is also adjacent to 1 ∈ U .
(b) A minimum chain cover of G with 3 chain subgraphs Z 1 , Z 2 , Z 3 (in different colors and dash styles), providing an independent proof that H is optimal. Here, Z 1 , Z 2 , Z 3 have disjoint edge sets, which is not necessarily the case in general. (c) The compact representation of G.
obvious certificate that the graph cannot contain an induced matching with more than W edges. We will elaborate on this aspect of a chain cover as a certificate of optimality in Section 5. A minimum chain cover of G is a chain cover with a smallest possible number of chain subgraphs. In a convex bipartite graph G, the maximum size of an induced matching is equal to the minimum number of chain subgraphs of a chain cover [24]. We denote the number of vertices by n U = |U |, n V = |V |, n = n U + n V , and the number of edges by m = |E|. If a convex graph is given as an ordinary bipartite graph without the proper numbering of V , it can be transformed into this form in linear time O(n + m) [2]. (In terms of the bipartite adjacency matrix, convexity is the well-known consecutive-ones property.) Unweighted convex bipartite graphs have a natural implicit representation [21] of size O(n), which is often called a compact representation [13,20]: every interval {L i , L i + 1, . . . , R i } is given by its endpoints L i and R i , see Figure 1(c). Since the numbering of V can be computed in O(n + m) time, it is easy to obtain a compact representation in total time O(n + m) [20,22]. The chain covers that we construct will consist of convex bipartite subgraphs with the same ordering of V as the original graph. Thus, we will be able to use the same representation for the chain graphs of a chain cover.
Related Work and Motivation. The problem of finding an induced matching of maximum size was first considered by Stockmeyer and Vazirani [23] as the "risk-free marriage problem" with applications in interference-free network communication. The decision version of the problem is known to be NP-complete in many restricted graph classes [4,16,15], in particular bipartite graphs [4,16] that are C 4 -free [16] or have maximum degree 3 [16]. On the other hand, it can be solved in polynomial time in chordal graphs [4], weakly chordal graphs [5], trapezoid graphs, k-interval-dimension graphs and co-comparability graphs [11], amongst others. For a more exhaustive survey we refer to [8].
The class of convex bipartite graphs was introduced by Fred Glover [10], who motivates the computation of matchings in these graphs with industrial manufacturing applications. Items that can be matched when some quantity fits up to a certain tolerance naturally lead to convex bipartite graphs. The computation of matchings in convex bipartite graphs also corresponds to a scheduling problem of tasks of discrete length on a single disjunctive resource [14]. The problem of finding a (classic, not induced) matching of maximum cardinality in convex bipartite graphs has been studied extensively [10,22,9] culminating in an O(n) algorithm when a compact representation of the graph is given [22]. Several other combinatorial problems have been studied in convex bipartite graphs. While some problems have been shown to be NP-complete even if restricted to this graph class [1], many problems that are NP-hard in general can be solved efficiently in convex bipartite graphs. For example, a maximum independent set can be found in O(n) time (assuming a compact representation) [20] and the existence of Hamiltonian cycles can be decided in O(n 2 ) time [18]. For a comprehensive summary we refer to [13].
One of the applications given by Stockmeyer and Vazirani [23] for the induced matching problem can be stated as follows. We want to test (or use) a maximum number of connections between receiver-sender pairs in a network. However, testing a particular connection produces noise so that no other node in reach may be tested simultaneously. We remark that this type of motivation extends very naturally to convex bipartite graphs when we consider wireless networks in which nodes broadcast or receive messages in specific frequency ranges. Further, weighted edges can model the importance of connections.
Previous Work. Yu, Chen and Ma [24] describe an algorithm that finds both a maximumcardinality induced matching and a minimum chain cover in a convex bipartite graph in runtime O(m 2 ). Their procedure is improved by Brandstädt, Eschen and Sritharan [3], resulting in a runtime of O(n 2 ). Chang [6] computes maximum-cardinality induced matchings and minimum chain covers in O(n + m) time in bipartite permutation graphs, which form a proper subclass of convex bipartite graphs. Recently, Pandey, Panda, Dane and Kashyap [19] gave polynomial algorithms for finding a maximum-cardinality induced matching in circular-convex and triad-convex bipartite graphs. These graph classes generalize convex bipartite graphs.
Our Contribution. We improve the previous best O(n 2 ) algorithm [3] for maximum-cardinality induced matching and minimum chain covers in convex bipartite graphs in several ways. In Section 2 we give an algorithm for finding maximum-weight induced matchings in convex bipartite graphs with O(n + m) runtime. The weighted problem has not been considered before. In Section 3 we specialize our algorithm to find induced matchings of maximum cardinality in O(n) runtime, given a compact representation of the graph. In Section 4 we extend this approach to obtain in O(n) time a compact representation of a minimum chain cover. If no compact representation is given, our approach is easily adapted to produce a minimum chain cover in O(n + m) time.
All of our algorithms achieve optimal running time for the respective problem and model. Our results for finding a maximum-cardinality induced matching also improve the running times of the algorithms of Pandey et al. [19] for the circular-convex and triad-convex case, as they use the convex case as a building block.

Maximum-Weight Induced Matchings
In this section, we compute a maximum-weight induced matching of a given edge-weighted convex bipartite graph G = (U, V, E) in time O(n + m). We generally write indices i ∈ U as superscripts and indices j ∈ V as subscripts. We consider E as a subset of U ×V . We assume that V = {1, . . . , n U } is numbered as described in Section 1 and the interval {L i , L i +1, . . . , R i } ⊆ V of each vertex i ∈ U is given by the pair (L i ,R i ) of the left and right endpoint. Each edge (i, j) ∈ E has a weight C i j . Our dynamic-programming approach considers the following subproblems: For an edge (i, j) ∈ E, we define W i j as the cost of the maximum-weight induced matching that uses the edge (i, j) and contains only edges in U × {1, . . . , j}. The following dynamic-programming recursion computes W i j : The range over which the maximum is taken is illustrated in Figure 2. In this recursion, we build the induced matching H of weight W i j by adding the edge (i, j) to some induced matching H of weight W i j . We want H to be an induced matching: By construction, the edge (i , j ) is independent of (i, j), but we have to show that the other edges of H are also independent of (i, j). In order to prove this (Lemma 2), we use a transitivity relation between independent edge pairs.
Assume that (i , j ) and (i , j ) are independent, and (i , j ) and (i, j) are independent. Then (i , j ) and (i, j) are independent.
Proof. By Observation 1, any edge (i , j ) with j < j that is independent of (i, j) satisfies R i < j and j < L i . By Lemma 1, all other edges (i , j ) used to obtain the matching value W i j are also independent of (i, j).
We create a table in which we record the entries W i j . We assume that the intervals are sorted in nondecreasing order by L i , that is, We fill the table row by row proceeding from i = 1 to i = n U . Each row i is processed from left to right.
The only challenge in evaluating (1) is the maximum-expression, for which we introduce the notation M i j .
We discuss the computation of the leftmost entry W i L i later. When we proceed from W i j to W i j+1 we want to go incrementally from M i j to M i j+1 . Direct comparison of the respective defining sets leads to  We are in the process of filling row 30 from left to right. All rows with smaller index i have been processed and are filled with the entries W i j . Unprocessed entries are marked as "-". The figure does not show the rows in the order in which they are processed, but intervals with the same right endpoint R i = r are grouped together. The bold entries collect the provisional maxima P r in each group. By way of example, the encircled entry P 27 [20] = 54 is the maximum among the shaded entries of the intervals that end at R i = 27, ignoring the yet unprocessed entries. As we proceed from j = 27 to j = 28 in row 30, the intervals with R i = 27 become relevant. The maximum usable entry from these intervals is found in position 17 of this array, because 17 = L 30 − 1. The entry P 27 [17] = 44 is marked by an arrow. The next entry W 30 28 will be computed as C 30 28 + max{P 27 [17], P 26 [17], . . . , P 17 [17]}. (Some of these entries might not exist.) We can observe that the minimum over which P 27 [17] is defined involves no unprocessed entries (Lemma 3). When the next row i = 34 in the group with R i = 27 is later filled, it will be necessary to update P 27 .
In order to evaluate the maximum of the second set in (2) efficiently, we group intervals i with a common right endpoint R i = r together. Let S r be the earliest startpoint of an interval with endpoint r. If there are no intervals with endpoint r, we set S r := r. (It would be more logical to set S r := r + 1 in this case, but this choice makes the algorithm simpler.) We maintain an array P r [j] for S r ≤ j ≤ r that is defined as follows: row i has already been processed, In a sense, P r [j] is a provisional version of the expression max{ W i j | R i = r, j < j }, which takes into account only the already processed rows. For (2), we need the entry P j [L i − 1], and we will see that all relevant entries have already been computed whenever we access this entry. Thus, we rewrite (2): The condition L i − 1 ≥ S j ensures that the array index L i − 1 does not exceed the left boundary of the array P j . Also, the index L i − 1 never exceeds the right boundary j of the array P j , since L i < j + 1 ≤ R i , and therefore L i − 1 ≤ j. Thus, P j [L i − 1] is always defined when it is accessed.
Proof. We distinguish three cases. Case 1: No interval ends at j, and accordingly, S j = j.
In this case M i j+1 = M i j in (2) since its rightmost set is empty. Since L i < j + 1 ≤ R i , we have L i − 1 < S j = j and, thus, the right side of (3) evaluates also to M i j . Case 2: There exists an interval ending at j, and L i − 1 < S j . The right side of (3) evaluates to M i j . In (2), intervals i that end at R i = j have L i ≥ S j > L i − 1. Thus, an edge (i , j ) with j < L i and R i = j does not exist, and the second set in (2) is empty. Therefore, (2) evaluates to M i j+1 = M i j . Case 3: There exists an interval ending at j, and L i − 1 ≥ S j . In this case, P j [L i − 1] is defined: For each entry W i j with j < L i , we conclude that L i ≤ j < L i and, thus, row i has already been processed. This means that the condition that row i was processed is redundant, and (4) coincides with the right side of (2).
After processing row i with startpoint = L i and endpoint r = R i , we have to update the values in P r [j]. This is straightforward. Figure 3 illustrates the role of the arrays P r [j] when processing a row.
It remains to discuss the computation of the first value W i of the row. An edge (i , j ), j < and edge (i, ) are independent if and only if the interval i ends before , that is R i < . Since we process the intervals in nondecreasing order by their startpoints, it suffices to maintain a value F with the maximum W i j in all finished intervals: those intervals i that end before . In other words F = max{P 1 [1], P 2 [2], . . . , P −1 [ − 1]}. This value is easily maintained by updating F as increases. The full details are stated as Algorithm 1.
The update of the array P r [j] in the second loop can be integrated with the computation of W i j in the first loop. When this is done, the values W i j need not be stored at all because they are not used. As stated earlier, when no interval ends at a point r ∈ V , we set S r = r. The array P r consists of a single dummy entry P r [r] = 0. This way we avoid having to treat this special cases during the algorithm.
We have described the computation of the value of the optimal matching. It is straightforward to augment the program so that the optimal matching itself can be recovered by backtracking how the optimal value was obtained, but this would clutter the program.

Maximum-Cardinality Induced Matchings
For the unweighted version of the problem, we assume a compact representation of a convex bipartite graph G = (U, V, E), that is, for each i ∈ U we are given the startpoint L i and endpoint R i of its interval {L i , L i + 1, . . . , R i }. This makes it possible to obtain a linear runtime of O(n).
The recursion (1) can be specialized to the unweighted case by setting C i j ≡ 1.
, q} F := max{F, P [ ]} update F as is incremented return F the maximum weight of an induced matching This recursion has already been stated in [24] and [3] in a slightly different formulation. Yu, Chen and Ma [24] describe it as a greedy-like procedure that "colors" the edges of a bipartite graph with the values W i j . From this coloring, they obtain both a maximum-cardinality induced matching and a minimum chain cover. The original implementation given in [24] runs in time O(m 2 ). Brandstädt, Eschen and Sritharan [3] give an improved implementation of the coloring procedure with runtime O(n 2 ). Our Algorithm 1 from Section 2 obtains the values W i j in total time O(n + m).
Given a compact representation, we can exploit some structural properties of the filled dynamic-programming table to further improve the runtime to O(n). The following observations were first given in [24] and [3]. Proof. This is obvious from (5), since the set over which the maximum is taken increases with j. Proof. Let W i j be the largest value in some row i. Then, if we take a corresponding matching of size W i j , it is easy to see that we can remove the last two edges and replace them by an arbitrary edge (i, k). This proves that W i k ≥ W i j − 1. More formally, we can argue by the recursion (5): Assume there are values W i k ≤ W i j − 2 in row i. By Lemma 4 we can assume k < j. By (5), W i j = 1 + W i j = 2 + W i j with R i < j < L i Set Q 1 := Q 2 := · · · := Q n U := 0 F := 0 for := 1 to n V do for all rows i ∈ U with L i = do Process each interval i that starts at w := F + 1 leftmost entry t w := leftmost endpoint R i of a row i that contains an entry W i j = w with j < L i ≡ if t w < R i then There are two values w and w + 1 in this row: The largest entry is w + 1. else The same entry w is used for the whole row.
The largest entry is w. F := max{F, Q } update F as advances return F for some i < i < i. Thus, j ≤ R i < j < L i ≤ k and by definition of W i k according to (5) we which is a contradiction.
Specializing Algorithm 1 to the unweighted case leads to a solution with O(m) running time. Our O(n)-time algorithm will follow the general scheme of Algorithm 1, with the following modifications.
• In view of Lemmas 4 and 5, we will not fill each row individually, but we will just determine the leftmost value w and the position where the entries switch from w to w + 1 (if any).
• The computation of the leftmost entry is exactly as in Algorithm 1.
• The position where the entries of row i switch from w to w + 1 can be determined from (5): If there is a row i containing an entry w left of L i , then W i j must be w + 1 as soon as j > R i . The algorithm determines the threshold position t w as the smallest right endpoint R i under these constraints. Then the entries w + 1 in row i start at j = t w + 1 if these entries are still part of the row.
• We do not maintain the whole array P r for each r, but only its last entry P r [r]; this is sufficient for updating F and thus for computing the leftmost entries in the rows. We call this value Q r .
This leads to Algorithm 2. We will improve Algorithm 2 by maintaining the values t w instead of computing them from scratch. We use the fact that the smallest value w in the row is known, and hence we can associate t w with the value w instead of the row index i, as is already apparent from our chosen notation. We update t w whenever increases. The details are shown in Algorithm 3. The differences to Algorithm 2 are marked by .
This still does not achieve O(n) running time. The final improvement comes from realizing that it is sufficient to update t w when W i l is the leftmost entry w in row i . The time when such an update occurs can be predicted when a row is generated. To this end, we maintain a list T j for j = 1, . . . , n V that records the updates that are due when becomes j. This final version is Algorithm 4.
The runtime of Algorithm 4 is O(n U + n V ): Processing each interval i takes constant time and adds at most two pairs to the lists T . Thus, processing the lists T for updating the t w array takes also only O(n U ) time.

Algorithm 3: Unweighted Maximum Matching, second version
Set t 1 := t 2 := · · · := t n U := n V + 1 The value n V + 1 acts like ∞. Set Q 1 := Q 2 := · · · := Q n U := 0 F := 0 for := 1 to n V do for all rows i ∈ U with L i = do Process each interval i that starts at w := F + 1 leftmost entry t w is no longer computed from scratch if t w < R i then There are two values w and w + 1 in this row: The largest entry is w + 1. else The same entry w is used for the whole row.
The largest entry is w. F := max{F, Q } update F as is incremented for all entries W i in column do w := W i t w := min{t w , R i }; return F Some simplifications are possible: The addition of (w, R i ) to the list T in the case of two values can actually be omitted, as it leads to no decrease in t w : t w is already < R i . The algorithm could be further streamlined by observing that at most two consecutive values of t w need to be remembered at any time.
Again, it is easy to modify the algorithm to return a maximum induced matching in addition to its size.

Minimum Chain Covers
In convex bipartite graphs, the size of a maximum-cardinality induced matching equals the number of chain subgraphs of a minimum chain cover [24]. In this section we use this duality and extend our Algorithm 4 to obtain a minimum chain cover of a convex bipartite graph G = (U, V, E).
Let W * be the cardinality of a maximum induced matching of G. Accordingly, the values W i j cover the range {1, . . . , W * }. We create W * chain subgraphs Z 1 , . . . , Z W * of G. The edges (i, j) with W i j = w will be part of the chain subgraph Z w . As already observed in [24], the edges with a fixed value of W i j may contain independent edges and, thus, do not necessarily constitute a chain graph. Accordingly, Yu, Chen, and Ma [24] describe a strategy to extend the edge set for each value of W i j = w to a chain graph Z w . Their original implementation runs in time O(m 2 ). Brandstädt, Eschen, and Sritharan [3] give an improved implementation with runtime O(n 2 ). We implement their strategy in O(n) time, given a compact representation. The correctness was already shown in [24]. We give a new independent proof. The following characterization is often used as an alternative definition of chain graphs:  Initialize lists T 1 , . . . , T n V to empty lists Set t 1 := t 2 := · · · := t n U := n V + 1 Set Q 1 := Q 2 := · · · := Q n U := 0 F := 0 for := 1 to n V do for all rows i ∈ U with L i = do Process each interval i that starts at w := F + 1 leftmost entry if t w < R i then There are two values w and w + 1 in this row: W i j = w for j = L i , . . . , t w , W i j = w + 1 for j = t w + 1, . . . , R i . add (w +1, R i ) to the list T tw+1 don't forget to update t w+1 when reaches t w + 1 add (w, R i ) to the list T don't forget to update t w when advances Q R i := max{Q R i , w + 1} else The same entry w is used for the whole row. add (w, R i ) to the list T Q R i := max{Q R i , w} F := max{F, Q } update F as advances for all (w, r) ∈ T do t w := min{t w , r} perform the necessary updates return F Proof. This is a direct consequence of the fact that edges (i, j) and (i , j ) are independent if and only if j / ∈V (i) and j / ∈V (i ).   (5), there is an edge (i , j ) with W i j = w, R i < E i w and j < L i < L i . Again by (5), such an edge (i , j ) would imply that W i E i w ≥ w + 1, a contradiction. This duality relation for perfect graphs extends to the weighted version. Thus, there should also be a weighted chain cover with the same weight as the maximum weight of an induced matching. It would be interesting to extend our primal Algorithm 1 in weighted graphs to a fast combinatorial algorithm for finding minimum-weight chain covers, as Algorithm 5 does for the unweighted version.