









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Professor: Simon; Class: Analysis of Algorithms; Subject: Computer Science; University: California State University-East Bay; Term: Summer 2001;
Typology: Study notes
1 / 16
This page cannot be seen from the preview
Don't miss anything!
CS 4245 I. Fundamental concepts 01/08/ These class-notes were prepared by Saruney Elebiary, and revised by Professor Simon.
Claim: G 1 is maximal connected Suppose (by contradiction) : G 1 is not connected So G 2 such that G 1 G 2 and G 2 is connected. Hence x is a vertex of G 2 Let y be the vertex of G 2 Since G 2 is connected x – y walk in G 2 So this walk is a walk in G So y V 1 So G 1 and G 2 have the same vertices Every edge of G 2 is also an edge of G 1 , because it joins 2 vertices of V 1 , and also it is in G 1 , because G 1 is induced. So G 1 = G 2 Hence G 1 is maximal connected. To prove:
A walk from x to y is closed if x = y A cycle x 0 , x 1 , …, xi is a closed walk of length at least 3 such that x 0 x 1 …xi-1 is a path A graph G = (V, E) is bipartite if V 1 , V 2 V V = V 1 V 2 , V 1 V 2 = such that every edge joins a vertex in V 1 to a vertex in V 2. Theorem 2: A graph is bipartite iff it contains no odd cycles. Length of a cycle is number of edges of cycle. The distance from x to y in G = dG(x, y) is the length of a shortest path from x to y if one exists, ??? or otherwise. Proof: (=>) Suppose G contains an odd cycle, say x 0 x 1 x 2 … xi And l is odd If G were bipartite, with vertex sets V 1 , V 2 , w.l.o.g. (without loss of generality) let x 0 V 1 So every even # end vertex is in V 1 and every odd # end vertex is in V 2 So x 2 V 2 impossible. since x 0 = xi and V 1 V 2 = (<=) w.l.o.g. assume G is connected Let x be a vertex. V 1 = { u V | da(x, u) is even} V 2 = { u V | da(x, u) is odd} Suppose claim is not true: So u,v such that u,v V 1 or u,v V 2 and uv E. Since G is connected, clearly V = V 1 V 2
In the 1st^ case: d(x, u) and d(x, v) are both even. Otherwise d(x, u) and d(x, v) are both odd In both cases we have a closed walk of odd length. Claim: This partition of the vertices works! In other words every edge joins a vertex in V 1 to a vertex in V 2. Let a shortest path from x to u be x 0 x 1 x 2 … xr = u Let a shortest path from x to v be y 0 y 1 y 2 … ys = v We have x 0 = y 0 = x Since both paths are shortest if xi = yj then i = j Let x’ be the vertex on path x 0 x 1 … xi = u While is also on path y 0 y 1 …ys = v with large index x’ = xi = yj then xi…xr = u v = ysys-1…yi is an odd cycle
Since x 0 x 1 … xl is a path it follows this is a cycle. (2) If G is maximal acyclic then G is a tree. So G is acyclic, so it only remains to show that G is connected. Pick x,y two arbitrary vertices To show x-y path in G. If xy E we are done. Otherwise G + xy has a cycle Since G has no cycles, this cycle must include xy Let cycle be x = x 0 x 1 x 2 …xl = y x = x 0 So x = x 0 x 1 x 2 …xl = y is a path in G + xy and l 2 So none of the edges of x 0 x 1 … xl is xy. So this path is in G and we are done. (3) G is tree => G is minimal connected. Since G is a tree it is connected. So it remains to prove that G is minimal connected i.e. xy E, G – xy is not connected Pick an arbitrary edge xy, and consider G – xy. Suppose G – xy is connected. So a path from x to y in G – xy. x = x 0 x 1 x 2 …xl = y has length at least 2. So x = x 0 x 1 x 2 …xl = y x is a closed walk of length 3 in G. Furthermore since x 0 x 1 …xl is a path, it is a cycle. Contradiction since G is acyclic.
(4) If G is minimal connected then G is a tree. G is connected. So it remains to show that G is acyclic. Suppose not. Then G has a cycle. Say x = x 0 x 1 x 2 …xl x 0 l 2 So xl x 0 E. Hence G – xlx 0 is not connected. But x 0 x 1 x 2 …xl is a path in G – xlx 0 Contradiction. Theorem 4: Every non-trivial tree contains a vertex of degree 1. Proof: Suppose not. Then G nontrivial tree such that it has no vertex of degree 1. Then the minimum degree of G cannot be 0 because G is Connected, so it can have no isolated vertices. So minimum degree is at least 2. So G contains a cycle. Contradiction. Exercise: nontrivial tree has at least 2 vertices of degree 1.
vuE f(v u) = (^) uvE f(u v) Max Flow Min Cut Theorem: maximum flow value = minimum cut capacity separating s and t. To prove: (i) f is maximum flow iff (ii) there is no augmenting path in the residual network iff (iii) value of flow f = capacity of some cut separating s and t.
G = (V, E) directed s V source c : E -> R t V sink f : E -> R (1) xy E f (xy) c (xy) (2) u V – {s, t} vu E f (vu) = uv E f (uv) maximize the flow from s to t value of flow f = sv E f (sv) - vs E f (vs) Easy to prove: (exercise) Value of flow = vt E f (vt) - tv E f (tv) A cut that separates s from t X V s X t X _ Cut (X, X ) = set of edges that join a vertex in X to a vertex not in X, or vice-versa. The capacity of a cut c(X,X) is defined to be = xy E, x X and not ( y X) c (xy), that is it is the sum of the capacities of all the edges that join a vertex in X to a vertex outside of X. _ Value of f c ( X, X) Gf = (V, Ef) xy E Ef = { xy E | c (xy) – f (xy) > 0 } { yx | xy E & f (xy) > 0 } cf (xy) = c (xy) – f (xy) cf (yx) = f (xy)
(2) Compute residual network Gf. (3) Search for an augmenting path. (by breadth first search) If we find it, increase flow and repeat. Otherwise halt, we have maximum flow. Every iteration will cost O (n + m) So O (k (n + m)) k = number of iterations