rest of network flow material
Project Selection Problem
Input: A directed graph (precedence graph) and a value (which can be negative) for each node .
Output: A set of nodes with no outgoing edges, such that the value is maximized.
Note: In the project selection problem, the input graph is not required to be acyclic. A cycle in the precedence graph represents a group of projects such that if one is selected, all must be selected. Thus, such a cycle can be contracted into a single node with a value representing all nodes (projects) in . This process can be repeated until a directed acyclic graph is obtained.
Algorithm for the Project Selection Problem
-
Construct a flow network:
- Add a source and an edge with capacity for each node with .
- Add a sink and an edge with capacity for each node with .
- Edges of the precedence graph are given infinite capacity.
-
Compute a minimum cut in the resulting network, and return the set of nodes .
Correctness of the Algorithm
Let be a cut in the constructed flow network. Then is a valid solution to the project selection problem if and only if there is no edge of the precedence graph (an edge with infinite capacity) leaving , i.e., if and only if has finite capacity.
Let and assume the value of is zero. The set is a cut with finite capacity , so if is a minimum cut, then has finite capacity.
We now prove that for any cut , it holds that:
Thus, the problem of maximizing the value of is equivalent to minimizing the capacity of .
Proof:
-
.
-
It is also evident that: .
-
Subtracting the second equation from the first eliminates the term , yielding: .
-
Hence: , as required.
Distribution Problem
Input: A directed graph with capacities and a demand (which can be negative) for each node .
Question: Is there a distribution—a function on the edges—satisfying:
- Capacity constraints: for all .
- Demand conditions: for all .
Definition: Nodes with negative demand are called sources, and nodes with positive demand are called sinks.
Let be the set of sources, and the set of sinks.
Algorithm for the Distribution Problem
-
Construct a flow network :
- Add a super-source and an edge with capacity for all .
- Add a super-sink and an edge with capacity for all .
-
Compute a maximum flow from to in the resulting network.
-
If , return “There exists a distribution” (the restriction of to edges in is a distribution). Otherwise, return “No distribution exists.”
Correctness of the Algorithm
Suppose a distribution exists. Extend to a flow in the network as follows:
- for all ,
- for all ,
- otherwise.
Since satisfies the demand conditions, is a flow of value .
Conversely, suppose there is a flow in of value . Then all edges leaving or entering are saturated. From this, it is easy to deduce that the restriction of to edges in is a distribution.
Note: From the proof of correctness, it follows that a necessary condition for the existence of a distribution is .
Theorem: A distribution exists in the network if and only if and for all , it holds that: . (The proof is left as an exercise.)