Determine whether a flow can satisfy node demands in a directed acyclic graph
-
29-09-2020 - |
Question
I have the following problem that I'm unsuccessfully trying to solve:
I have a directed graph with node demands. Unlike circulation with demands, these node demands do not "subtract" from the flow - the nodes merely demand that there would be a flow of strength k flowing through them. The graph is acyclic, however, it is not a tree - multiple routes exist from the higher to the lower nodes.
The question is, whether a flow of strength R can satisfy all of the nodes' demands. Of course, a flow with strength more than k can flow through a node with demand k. Also, there are no capacity limits in the input graph.
I need to reduce this problem to the max-flow problem. I have been trying to reduce it to Circulation with lower bounds and Circulation with demands, but unsuccessfully, as I am unable to find out a good way on how to somehow limit the flow in the nodes to be minimal while satisfying the demands and measuring it at the same time.
Solution
Add a new source $s'$ and the edge $(s', s)$ with maximum and minimum capacity $R$.
For each vertex $v$ with demand $d$ do the following:
- Replace $v$ with two vertices $v_1$ and $v_2$.
- Replace all the former edges $(u,v)$ with $(u, v_1)$
- Replace all the former edges $(v, u)$ with $(v_2, u)$.
- Add the edge $(v_1, v_2)$ with minimum capacity $d$.
The problem is now equivalent to checking whether there exists a feasible flow in a network with minimum and maximum edge capacities.
This problem is well known and can be reduced to max-flow (see, e.g., "Balances and Pseudoflows" in the book Algorithms by Jeff Erickson).
Essentially, if $D$ is the sum of all the edges' minimum capacities:
- Add a new source vertex $s^*$ and a new target vertex $t^*$.
- Add the edge $(s^*, s')$ with maximum capacity $+\infty$.
For each edge $(u,v)$ with minimum capacity $c \neq 0$ and maximum capacity $C$, add the edge $(u, t^*)$ with capacity $c$, the edge $(s^*, v)$ with capacity $c$, remove the minimum capacity from $(u,v)$, and change the maximum capacity of $(u,v)$ to $C-c$ (if $C$ was $+\infty$ then the new capacity is also $+\infty$).
Check whether the maximum flow from $s^*$ to $t^*$ is equal to $D$.