26-2 Minimum path cover
A path cover of a directed graph is a set of vertex-disjoint paths such that every vertex in is included in exactly one path in . Paths may start and end anywhere, and they may be of any length, including . A minimum path cover of 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 . ( Assuming that , construct the graph , where
and run a maximum-flow algorithm.)
b. Does your algorithm work for directed graphs that contain cycles? Explain.
a. Set up the graph as defined in the problem, give each edge capacity , and run a maximum-flow algorithm. I claim that if has flow in the maximum flow and we set 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 for some . However, this contradicts the conservation of flow, since the capacity leaving is only . Moreover, since the capacity from to is , we can never have two edges of the form and for . We can ensure every vertex is included in some path by asserting that if there is no edge or for some , then will be on a path by itself. Thus, we are guaranteed to obtain a path cover. If there are paths in a cover of vertices, then they will consist of edges in total. Given a path cover, we can recover a flow by assigning edge flow if and only if is an edge in one of the paths in the cover. Suppose that the maximum flow algorithm yields a cover with paths, and hence flow , but a minimum path cover uses strictly fewer than paths. Then it must use strictly more than 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 on , section 26.3 tells us that we can find a maximum flow in .
b. This doesn't work for directed graphs which contain cycles. To see this, consider the graph on which contains edges , , , and . The desired output would be a single path , , , but flow which assigns edges , , and flow is maximal.