ford-fulkerson's labeling algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... ·...

49
. . . . . . . . by L A T E X . . Ford-Fulkerson’s Labeling Algorithm Luke Zhou December 10, 2018 Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Upload: others

Post on 25-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. by LATEX

.

......Ford-Fulkerson’s Labeling Algorithm

Luke Zhou

December 10, 2018

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 2: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Ford-Fulkerson’s Method

Ford-Fulkerson-Method(G , s, t)

1 initialize flow f to 02 while there exists an augmenting path p in the residual network Gf

3 augment flow f along p4 return f

“We call it a ‘method’ rather than an ‘algorithm’ because itencompasses several implementations with differing running times.”

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 3: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Ford-Fulkerson’s Method

Ford-Fulkerson-Method(G , s, t)

1 initialize flow f to 02 while there exists an augmenting path p in the residual network Gf

3 augment flow f along p4 return f

“We call it a ‘method’ rather than an ‘algorithm’ because itencompasses several implementations with differing running times.”

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 4: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. The Ford-Fulkerson Labeling Algorithm: Convention

First, a convention:

The algorithm begins with a linear order on the vertex setwhich establishes a notion of precedence.

Typically, the first vertex in this linear order is the sourcewhile the second is the sink.

After that, the vertices can be listed in any order.

We will use the following convention: the vertices will belabeled with capital letters of the English alphabet and thelinear order will be (S ,T ,A,B,C ,D,E ,G , ...), which we willrefer to as the pseudo-alphabetic order

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 5: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Three States

In carrying out the labeling algorithm, vertices will be classified as:

labeled

scannedunscanned

unlabeled

The form of a label (a triple):

(VERTEX ,SIGN(±),POTENTIAL)

where VERTEX is the ID of a vertex, SIGN is + or −, andPOTENTIAL is a positive real number.

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 6: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Two Routines

.Routine A..

......

(General Step) Select a node, x , that is labeled and unscanned.

To all unlabeled successor nodes, y , such thatf (x , y) < c(x , y), assign the label (x ,+, p(y)) wherep(y) = min{p(x), c(x , y)− f (x , y)}.To all unlabeled predecessor nodes, y , such that f (y , x) > 0,assign the label (x ,−, p(y)) where p(y) = min{p(x), f (y , x)}.

Repeat the general step until

the sink is labeled and unscanned: go to Routine B;

no more labels can be assigned: terminate.

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 7: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Two Rules

First Labeled, First Scanned: the important rule is that wescan vertices in the order that they are labeleduntil we labelthe sink. (This aspect of the algorithm results in abreadth-first search of the vertices looking for ways to labelpreviously unlabeled vertices.)

Never Relabel a Vertex: Once a vertex is labeled, we do notchange its label.

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 8: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Two Routines

.Routine B..

......

(Flow Updating) The sink has been labeled (y ,±, p(t)).

If the second part of the label is +; replace f (y , t) withf (y , t) + p(t);

otherwise, replace f (t, y) with f (t, y)− p(t).

Go to node y , and treat it the same way. Repeat until the sourceis reached. Then discard all labels and return to Routine A.

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 9: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. What Happens When the Sink is Labeled?

The labeling algorithm halts if the sink is ever labeled.

Now suppose that the sink is labeled with the triple (u,+, a). Weclaim that we can find an augmenting path p which results in anincreased flow with δ = a, the potential on the sink.

To see this, we merely back-track. The sink T got its label fromu = u1, u1 got its label from u2, and so forth. Eventually, wediscover a vertex um which got its label from the source. Theaugmenting path is then p = (S , um, um−1, ..., u1,T ).

The value of δ for this path is the potential p(T ) on the sink sincewe’ve carefully ensured thatp(um) ≥ p(um−1) ≥ ... ≥ p(u1) ≥ p(T ).

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 10: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Termination

This process will be repeated until we reach a point where thelabeling halts with some vertices labeled (one of these is thesource) and some vertices unlabeled (one of these is the sink).We will then note that the partition V = L ∪ U into labeled andunlabeled vertices is a cut whose capacity is exactly equal to thevalue of the current flow.

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 11: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 12: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 13: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 14: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 15: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 16: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 17: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 18: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 19: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 20: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 21: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 22: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 23: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 24: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 25: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 26: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 27: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 28: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 29: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 30: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 31: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 32: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 33: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 34: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 35: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 36: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 37: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 38: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 39: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 40: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 41: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 42: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 43: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 44: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 45: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 46: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 47: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 48: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm

Page 49: Ford-Fulkerson's Labeling Algorithmcslabcms.nju.edu.cn/problem_solving/images/f/f2/3-12... · 2018-12-12 · The Ford-Fulkerson Labeling Algorithm: Convention First, a convention:

. . . . . .

.. Example

Luke Zhou Ford-Fulkerson’s Labeling Algorithm