200 likes | 313 Views
Theorem 5 . 22 : Let T be built according to Huffman algorithm and leaves of T with weight w 1 w 2 w n . Then T is an optimal tree. Proof: Let us apply induction on the number n of vertices. n=2,. The results holds Suppose that result holds for n=k-1 For n=k ,
E N D
Theorem 5.22: Let T be built according to Huffman algorithm and leaves of T with weight w1w2 wn. Then T is an optimal tree. • Proof: Let us apply induction on the number n of vertices. • n=2, The results holds Suppose that result holds for n=k-1 For n=k, By the inductive hypothesis, Suppose that nodes in an optimal tree T have weights w1+w2,w3,,wk. Then This is an optimal tree with weight w1w2w3wkif T’s leaf with weight w1+w2 is replaced by subtree
Lemma 5.1 Let T1 be an optimal tree with weights w1w2w3 wk. Then there is an optimal tree T2 so that T2’s two vertices with weights w1 and w2 are brother nodes. • Proof: Let T1 be an optimal tree with weights w1w2w3wk • The two weights wa ,wb are on lowest level and they are brothers. We denoted by va and vb. Let v0 be the father of va, vb. • waw1, wbw2. • Let la be the length of the path from root to va, and lb be the length of the path from root to vb. • la=lb • We obtain a new tree T2by exchanging from leaf v1 to va and from leaf v2 to vb. • w(T1)-w(T2)=(wa-w1)(la-l1)+ (wb-w2)(la-l2)0
Lemma 5.2: Suppose that nodes of an optimal tree T have weights w1+w2,w3,,wk. Then this is an optimal tree with weight w1,w2,w3,,wk if T*’s leaf with weight w1+w2 is replaced bysubtree Proof: By the Lemma 5.1,there is an optimal tree T2 with weight w1,w2,w3,,wk so that T2’s two vertices with weights w1 and w2 are brother nodes. Let l1 be the length of the path from root to v1 with weight w1. Let T2* be a same tree as T2 without leaf with weight w1 and leaf with weight w2, but with a having leaf of weight w1+w2. w(T2*)=w(T2)-w1l1 - w2l1 +(w1+w2)(l1-1) Thus w(T2)=w(T2*)+w1+w2 Let T* be a same tree as T without leaf with w1+w2 but with subtree Suppose that T* is not an optimal tree.
Theorem 5.22:Proof: Let us apply induction on the number n of vertices. • n=2, The results holds Suppose that result holds for n=k-1 For n=k,By the inductive hypothesis, the tree with weight w1+w2,w3,,wkby according to Huffman algorithm is an optimal tree . By lemma 5.2, this is an optimal tree with weight w1,w2,w3,,wk if T’s leaf with weight w1+w2 is replaced by subtree
5.7 Transport Networks • 5.7.1 Transport Networks • Definition 33: A transport network or a network, is a connected digraph N(V,E,C) with the following properties: • (1)N has no loop. • (2)There is a unique node s, the source, that has in-degree 0. And there is a unique node t, the sink, that has out-degree 0. • (3)The graph is labeled. The label, cij on edge (i,j) is a nonnegative number called the capacity of the edge. Let C={cij |(i,j)E}.
Definition 34: A flow in a network N(V,E,C) is a function that assigns to each edge (i,j) of N a nonnegative number fij that does not exceed cij. A conservation flow is a flow with the properties: • for each vertex other than the source and sink. The sum • is called the value of the conservation flow. A conservation flow f is called maximum flow, if vf ≥vf’ for any conservation flow f ’ of N.
Definition 35: Let N be a network with the source node and the sink node. If P is a subset of V containing source s but not sink t then E(P,V-P)is called a cut separating s from t. • In effect, a cut does “cut” a digraph into two pieces, one containing the source and one containing the sink. If the edges of a cut were removed, it has not any paths from source to sink.
The capacity of a cut E(P,V-P)is , we denote by C(P,V-P). i.e.
A cut E(P,V-P) of N is called minimum cut, if C(P,V-P)≤C(P',V-P') for any cut E(P',V-P') of N. • Theorem 5.23: For every conservation flow f and any cut E(P,V-P), the result holds: VfC(P,V-P). • VfC(P,V-P), • VfmaxCmin(P,V-P)
5.7.2 A Maximum flow algorithm • Lemma 5.3: Let f be a conservation flow, E(P,V-P) be a cut. If Vf=C(P,V-P),then Vfmax=Vf ,Cmin(P,V-P)=C(P,V-P). • Proof: By the theorem 5.23, • Theorem 5.23: For every conservation flow f and any cut E(P,V-P), the result holds: VfC(P,V-P).
Frod,Falkerson • 1956 • 1)We construct a initial conservation flow in N(V,E,C) • Generally, we set fij0=0 for every edge (i,j) of N. The conservation flow is called zero flow. • 2)We shall construct an increasing sequence of flows f 1, f 2,…, f n, that has to terminate in a maximal flow. • How do we construct the increasing sequence?
Let u be an undirected path from s to t, • (1)When u is a directed path from s to t, if fij<cij for every edge of the path, then we change fij for every edge of the path, which equals min{cij-fij} • 1)Label s with (-,Δs), where Δs=+∞ • 2)Suppose that vertex i is labeled, Let j be an adjacent vertex of i, and no labeled. If fij<cij,then j is labeled (i+, Δj), where Δj = min{Δi,cij- fij} • 3)If t is labeled, then an increasing flow is constructed. We change fij to fij +Δt for every edge of the path u.
In the path (s,b,c,t) from s to t, edge (c,b) is reverse order .
Suppose that vertex b is labeled, If fcb>0,then c is labeled (b-,Δc), where Δc = min{Δb,fcb} • If t is labeled, then an increasing flow is constructed. • We change fij to fij +Δt when (i,j)E, if (i,j)E then we change fji to fji -Δt.
0) Construct a initial conservation flow in N(V,E,C). • 1) Label s with (-,+∞). • U={x|x is an adjacent vertex of s} • 2)Suppose that vertex i is labeled, and j is no labeled, where jU. • U=U-{j} • i) If (i,j)E and fij<cij, then • { j is labeled (i+, Δj), where Δj = min{Δi,cij- fij}, • U=U∪{x|x is an adjacent vertex of j}. goto 3) } • ii)If (j,i)E and fji>0,then • {j is labeled (i-, Δj), where Δj = min{Δi,fji}. • U=U∪{x|x is an adjacent vertex of j} } • If j is not labeled, then goto 4) • 3)If t is labeled then • { We change fij to fij +Δt . if j is labeled with i+. • If j is labeled with i-, then fji is changed to fji –Δt goto 1) • else goto 2) • 4)If U then goto 2) else stop.
Theorem 5.24: The labeling algorithm produces a maximum flow. • Proof: P={x|x is labeled when algorithm end},thus V-P={ x|x is not labeled when algorithm end}. • By the labeling algorithm, sP and tV-P. Thus E(P,V-P)is a cut. • (1) (i,j) E(P,V-P)(i.e. iP. jV-P) • fij=cij, • (2) (j,i) E (i.e. iP. jV-P) • fji=0. • By lemma 5.3, the labeling algorithm produces a maximum flow.
Exercise: P314 7,9,10,11,17,19, 20,21 • Graph Matching 8.5 P315