Professional Documents
Culture Documents
Out in Out In: - Single-Source Shortest/Longest Paths On DAG
Out in Out In: - Single-Source Shortest/Longest Paths On DAG
SPECIAL GRAPHS
c Steven & Felix, NUS
The answer for the motivating problem above is two taxis. In Figure 4.26.D, we see one possible
solution. One taxi (red dotted line) serves passenger 1 (colored with red), passenger 2 (blue), and
then passenger 4 (yellow). Another taxi (green dashed line) serves passenger 3 (green) and passenger
5 (orange). All passengers are served with just two taxis.
In general, the Min Path Cover (MPC) problem in DAG is described as the problem of finding the
minimum number of paths to cover each vertex in DAG G = (V, E).
This problem has a polynomial solution: Construct a bipartite graph G = (Vout Vin , E ) from
G, where Vout = {v ∈ V : v has positive out-degree}, Vin = {v ∈ V : v has positive in-degree},
and E = {(u, v) ∈ (V out, V in) : (u, v) ∈ E}. This G is a bipartite graph. Finding a matching on
bipartite graph G forces us to select at most one outgoing edge from v ∈ Vout (similarly for Vin ).
DAG G initially has n vertices, which can be covered with n paths of length 0 (the vertex itself).
One matching between vertex a and vertex b using edge (a, b) says that we can use one less path as
it can cover both vertices in a ∈ Vout and b ∈ Vin . Thus if the Max Cardinality Bipartite Matching
(MCBM) in G has size m, then we just need n − m paths to cover each vertex in G.
The MCBM in G that is needed to solve the MPC in G is discussed below. The solution for
bipartite matching is polynomial, thus the solution for the MPC in DAG is also polynomial. Note
that MPC in general graph is NP-Complete [42].
88