26-2 Minimum path cover

A path cover of a directed graph G=(V,E)G = (V, E) is a set PP of vertex-disjoint paths such that every vertex in VV is included in exactly one path in PP. Paths may start and end anywhere, and they may be of any length, including 00. A minimum path cover of GG is a path cover containing the fewest possible paths.

a. Give an efficient algorithm to find a minimum path cover of a directed acyclic graph G=(V,E)G = (V, E). (Hint:\textit{Hint:} Assuming that V={1,2,,n}V = \{1, 2, \ldots, n\}, construct the graph G=(V,E)G' = (V', E'), where

V={x0,x1,,xn}{y0,y1,,yn},E={(x0,xi):iV}{(yi,y0):iV}{(xi,yj):(i,j)E}, \begin{aligned} V' & = \{x_0, x_1, \ldots, x_n\} \cup \{y_0, y_1, \ldots, y_n\}, \\ E' & = \{(x_0, x_i): i \in V\} \cup \{(y_i, y_0): i \in V\} \cup \{(x_i, y_j): (i, j) \in E\}, \end{aligned}

and run a maximum-flow algorithm.)

b. Does your algorithm work for directed graphs that contain cycles? Explain.

a. Set up the graph GG' as defined in the problem, give each edge capacity 11, and run a maximum-flow algorithm. I claim that if (xi,yj)(x_i, y_j) has flow 11 in the maximum flow and we set (i,j)(i, j) to be an edge in our path cover, then the result is a minimum path cover. First observe that no vertex appears twice in the same path. If it did, then we would have f(xi,yj)=f(xk,yj)f(x_i, y_j) = f(x_k, y_j) for some ikji \ne k \ne j. However, this contradicts the conservation of flow, since the capacity leaving yjy_j is only 11. Moreover, since the capacity from ss to xix_i is 11, we can never have two edges of the form (xi,yj)(x_i, y_j) and (xi,yk)(x_i, y_k) for kjk \ne j. We can ensure every vertex is included in some path by asserting that if there is no edge (xi,yj)(x_i, y_j) or (xj,yi)(x_j, y_i) for some jj, then jj will be on a path by itself. Thus, we are guaranteed to obtain a path cover. If there are kk paths in a cover of nn vertices, then they will consist of nkn − k edges in total. Given a path cover, we can recover a flow by assigning edge (xi,yj)(x_i, y_j) flow 11 if and only if (i,j)(i, j) is an edge in one of the paths in the cover. Suppose that the maximum flow algorithm yields a cover with kk paths, and hence flow nkn − k, but a minimum path cover uses strictly fewer than kk paths. Then it must use strictly more than nkn − k edges, so we can recover a flow which is larger than the one previously found, contradicting the fact that the previous flow was maximal. Thus, we find a minimum path cover. Since the maximum flow in the graph corresponds to finding a maximum matching in the bipartite graph obtained by considering the induced subgraph of GG' on {1,2,,n}\{1, 2, \dots, n\}, section 26.3 tells us that we can find a maximum flow in O(VE)O(V E).

b. This doesn't work for directed graphs which contain cycles. To see this, consider the graph on {1,2,3,4}\{1, 2, 3, 4\} which contains edges (1,2)(1, 2), (2,3)(2, 3), (3,1)(3, 1), and (4,3)(4, 3). The desired output would be a single path 44, 33, 11, 22 but flow which assigns edges (x1,y2)(x_1, y_2), (x2,y3)(x_2, y_3), and (x3,y1)(x_3, y_1) flow 11 is maximal.