CS 573: Algorithms, Fall 2013
Homework 3: Solutions
Version 1.0
1. Prove infeasibility. (25 pts.)
You are trying to solve a circulation problem, but it is not feasible. The problem has demands, but no
capacity limit
...
CS 573: Algorithms, Fall 2013
Homework 3: Solutions
Version 1.0
1. Prove infeasibility. (25 pts.)
You are trying to solve a circulation problem, but it is not feasible. The problem has demands, but no
capacity limits on the edges. More formally, there is a graph G = (V, E), and demands dv for each node
v (satisfying ∑v∈V dv = 0), and the problem is to decide if there is a flow f such that f(e) ≥ 0 and
fin(v) − fout(v) = dv for all nodes v ∈ V . Note that this problem can be solved via the circulation
algorithm from Section 7.7 by setting ce = +∞ for all edges e ∈ E. (Alternately, it is enough to set ce to
be an extremely large number for each edge – say, larger than the total of all positive demands dv in the
graph.)
You want to fix up the graph to make the problem feasible, so it would be very useful to know why the
problem is not feasible as it stands now. On a closer look, you see that there is a subset U of nodes
such that there is no edge into U, and yet ∑v∈U dv > 0. You quickly realize that the existence of such a
set immediately implies that the flow cannot exist: The set U has a positive total demand, and so needs
incoming flow, and yet U has no edges into it. In trying to evaluate how far the problem is from being
solvable, you wonder how big the demand of a set with no incoming edges can be.
Give a polynomial-time algorithm to find a subset S ⊂ V of nodes such that there is no edge into S and
for which ∑v∈S dv is as large as possible subject to this condition.
Solution:
Compute the strong connected components of G – this can be done in linear time. Collapse every connected
component into a single super vertex. Let H be the resulting graph. The demand of a vertex v in H is
the total sum of the demands of the vertices of G collapsed into v. The graph H is no a directed acyclic
graph, and the project selection algorithm can be applied to H and compute the desired set.
As for how to compute the strong connected components – one can just repeatedly find a cycle in the
graph, and collapse it repeatedly. Finding a cycle can be done by doing a single DFS in the graph – fill
up your education if you do not know the details - this is an easy exam question
[Show More]