Créer une présentation
Télécharger la présentation

Télécharger la présentation
## What you misses!

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**What you misses!**Something very valuable was missing in a lab. There were 6 RA’s (A, B, C, D, E, F) working in the lab that night. If two persons are in the lab at the same time, at least one will see the other. No one can reenter the lab (every RA stays for a consecutive period of time). Upon investigation, each of them claims: A saw B,D. B saw A. C saw F. D saw A, B, C. E saw B, F. F saw B. Suppose there is only one liar among the RA’s who saw someone and did not tell. Can you identify a liar? Explain.**The investigation**• Construct a graph indicating the time overlap relations among the RA’s. • The graph should be an interval graph like the one below. B A F D C E**E**B F A C D But there is an induced cycle of length 4 (BDCF), A saw B,D. B saw A. C saw F. D saw A, B, C. E saw B, F. F saw B. This is not an interval graph! Either B or C lied!**What you probably won’t miss! (In the exam?)**• Which of the following is a DFS (BFS) sequence of Fig. 1? • Find an augmenting path in Fig.2. • Is the interval graph based on the model shown in Fig.3 Eulerian? • What can we say about the time complexity for recognizing interval graphs when we know that there is a O(nm) time for recognizing a circular-arc graph. (Interval graph is a subset of circular-arc graph.) • Find a min-cut on a network. • None of these above.**Network flow and Matching**• The problems that are hard but can be solved by poly-time algorithms. • Rich applications. • The area where graph algorithms meet linear programming (operating research).**Outline**• Bipartite matching. • Network flow. • Ford and Fulkerson’s algorithm. • Max-flow Min-cut theorem. • Efficient algorithms. • General Matching • Applications.**Matching Making Service**(MaMaServ) a 1 b 2 c 3 d 4 e 5 6**Matching Making Service**(MaMaServ) 1 2 3 4 5 6 a 1 a b 2 b c 3 c d d 4 e e 5 6**Matching Making Service**f joins in at the last minute a 1 b 2 c 3 d 4 e 5 f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**Matching Making Service**1 2 3 4 5 6 a 1 a b 2 b c 3 c d 4 d e 5 e f f 6**General Techniques for Flow and Matching**• Starting from a feasible solution. • Get a better solution by finding an augmenting path. • What’s the difference from a greedy method? • In a greedy algorithm, a decision will not be changed by subsequent operations.**Augmenting Path in Bipartite Matching**• Given a (partial) matchingM in a graph G, an augmenting path is a path with even number of vertices (odd number of edges) such that the two end point are unmatched vertices and the edges in the path are composed by unmatched and matched edges alternatively.**Augmenting path.**Repeat find an augmenting path modify the matching Until there is no augmenting path A path with odd length where both endpoints are not matched And all other vertices are matched.**a**1 b 2 c 3 is an augmenting path! d 4 e 5 a-4 c-2 d-3 e-6 f-5 f 6**Using BFS-like strategy to find an augmenting path**c 2 3 d a 1 b b 2 e 4 6 a 1 c 3 d 4 5 f e 5 f 6 • Complexity O(Fm) • F=the cardinality of matching. • O(nm)**Proof of correctness**• Suppose we cannot find any augmentation path in a bipartite graph and the cardinality is not maximum. • Denote the maximum matching by red edges and our partial result by blue edges. • Consider all possible relations of the two sets of edges.**Compare each red edge with blue matching.**Pick a red edge, if it was a blue edge, ignore. If it does not contain a matched edge, it is an augmenting path! Otherwise, traverse alone the matched edge… a 1 b 2 c 3 d 4 e 5 6 f Must have a augmenting path!**Transportation Network**1 3 3 2 2 2 s t 3 3 • Capacity c(e). • Feasible solution • Capacity constraint : 0<= f(e) <= c(e) for each e • Conservation constraint: fin(v) = fout(v) for each v • (except s, t) 1**1**3 3 2 2 2 s t 3 3 1 A forward augmenting path is a directed Path from s to t using forward edges. A flow is maximal if there is no Forward augmenting path.**1/1**1/3 1/3 2 2 2 s t 3 3 1 • A backward edge is added in the reversal • to the direction of the flow.**s**10 10 10 x y 10 10 t Cannot increase the flow without decrease the flow in certain edge. .**s**10 10 10 x y 10 10 t Redirection must be considered on existing flows. .**What do we mean by including a backward edge in an**augmenting path?**The flow can be increased by reverting some previously**allocated flow on a back edge.**Augmenting path: Forward and backward edges.**• The gain by adding an augmenting path is the minimum of the remaining capacity of a forward edge or the flow of a backward edge. • Update: increase the gain on the forward edges and subtract the gain from the existing flow of the backward edges.**Ford and Fulkerson**• Find an augmenting path. • Update the flow and data structure. • Until no augmenting path can be found. • Correctness: max-flow min-cut theorem.**Residual Graph**• The graph that we consider in the flow algorithm. • Consists both forward and backward edges (NO DIFFERENCE). • Updated when each augmenting path is selected.**3**5 5 2 2 1 3 3 6**3**5 5 2 2 1 3 3 Critical edge 6**1**3 2 5 2 2 2 1 1 3 4 2 2**1**3 2 5 2 2 2 1 1 3 4 2 Critical edge 2**1**3 3 2 2 2 2 2 1 1 1 2 2 2 4**1**3 3 2 2 2 2 2 1 1 1 2 2 2 4 Critical edge**1**2 2 2 3 3 1/1 2 1 1 1 2 2 2 4**1**2 2 2 3 3 1/1 2 1 1 1 2 2 2 4**3**1 1 4 4 1/1 2 1 1 1 2 2 2 4**3**1 1 4 4 1/1 2 1 1 1 2 2 2 4**3**1 1 4 4 1/1 2 1 3 1 3 5**The Ford-Fulkerson algorithm might not terminate(if the**initial values are not rational). • First poly-time algorithm is given by Edmonds and Karp.**s**1000 1000 1 1000 1000 t The worst case? x y s-x-y-t path.**1000**1000 1 1000 1000**1000**1000 1 1000 1000