Lecture 9
Yonghui Wu
Stony Brook University, Fudan University
[email protected]
Flow Networks
• A flow network G=(V, E) is a directed graph
in which each arc (vi, vj)∈E has a
nonnegative capacity Cij>0; and if there is
no arc from vertex vi to vertex vj, Cij=0. Two
vertices are distinguished in a flow
network: a source vertex s and a sink
vertex t. A flow in G is a real-valued
function f: V×V→R.
• A flow network satisfies following properties:
• (1) Capacity constraint: for each (u,
v) , .
• (2) Flow conservation:
for , .
• Given a flow network G(V, E) with source
vertex s and sink vertex t, and a flow f; we
are normally required to find the
maximum flow from the source s to the
sink t. The key to the problem is to find an
augmenting path p from s to t.
• Methods to find an augmenting path are as
follow.
• Depth-First Search (DFS);
• Breadth-First Search (BFS);
• Labelling Algorithm.
• Above algorithms add flow each time for
an augmenting path. If the maximum flow
is a, and the time finding an augmenting
path is m, the time complexity for
computing the maximum flow is O(a*m).
Power Network
• Source: ACM Southeastern Europe 2003
• IDs for Online Judge: POJ 1459, ZOJ 1734, UVA 2760
• SPFA algorithm can be used to calculate the augmenting path
from the source vertex st to the sink vertex en.
• Flows are as edges’ weights. The shortest path from the
source vertex st to the sink vertex en can be calculated. The
path is the augmenting path. Suppose h is the queue, pointers
for the front and rear for h are l and r respectively; and pre is
the precursor pointer in the augmenting path.
Trash
• IDs for Online Judge: Ural 1076