reference 【Introduction to Algorithm Chapter 26】
Problem Setting
We wish to compute the greatest rate at which we can ship material from the source to the sink without violating any capacity constraints.
1.1 Flow networkds
A flow network G =(V, E) is a directed graph in which each edge(u, v) belong to E has a nonnegative capacity c(u, v) >= 0.
We further require that if E contains a edge(u, v), then there is no edge(v, u) in the reverse direction.
If (u, v) is not belong to E, we define c(u, v) = 0,and we disallow self-loops.
the flow network contains : a source s and a sink t and other vertices. there is a path as s->v->t.
Definition: Leg G = (V, E) be a flow network with a capacity function c. let s be the source of the network, and let t be the sink. A flow in G is a real-valued function f: V X V -> R that satisfies the following two properties:
Capacity constraint: For all u, v belong to V, we require 0 <= f(u, v) <= c(u, v)
Flow conservation: For all u belog to V - {s, t}, we require(none source and none sink vertices)
when (u, v) is not belong to E, f(u,v) = 0
We call the nonnegative quantity f(u, v) the flow from vertex u to v ertex v. and the value |f| of a flow f is defined as
that is the total flow out of the source minus the flow into the source.
Modeling Problems with antiparallel edges
by the definition when (u, v) is belong to E, (v, u) is not belong to E, we can convert the flow by adding a virtual vertices if it violate the constraint, as: