1 / 45

5. Biconnected Components of A Graph

5. Biconnected Components of A Graph. If one city’s airport is closed by bad weather, can you still fly between any other pair of cities? If one computer in a network goes down, can a message be sent between any other pair of computers in the network?

fadey
Download Presentation

5. Biconnected Components of A Graph

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 5. Biconnected Components of A Graph If one city’s airport is closed by bad weather, can you still fly between any other pair of cities? If one computer in a network goes down, can a message be sent between any other pair of computers in the network? If any one vertex (and edges incident with it) is removed from a connected graph, is the remaining subgraph still connected?

  2. G I B G B I C B E C E E F F F J J H H D D A A (a) graph. (b) Its biconnected components Def’n: Let G=(V, E) be a connected, undirected graph. A vertex aV is said to be an articulation point if there exist vertex v and w such that (1) v, w and a are distinct (2) Every path between v and w must contain a. Alternatively, a is an articulation point of G if removing a splits G into two or more parts. subgraphs

  3. Def’n:A graph G =(V, E) is said to be biconnected if and only if it has no articulation points. G2 G3 G1 which of the above are biconnected? Def’n: Let G' = (V', E') be a biconnected subgraph of a graph G = (V, E). G' is said to be a biconnected component of G if G' is maximal i.e., not contained in any other biconnected subgraph of G. Example is shown in the previous page !!!

  4. Observation G = (V, E) Two edge e1and e2 in E is said to be related if e1 = e2 or if there is a cycle containing both e1 and e2. (e, e)  Re  E (e1 , e2)  R and (e2 , e3)  R  (e1 , e3)  R (e1 , e2)  R  (e2 , e1)  Rwhy ? Each subgraph consisting of the edges in an equivalent class and the incident vertex is a biconnected component !!! Can you prove it ?

  5. x a y Lemma: For 1 i k , Let Gi =(Vi , Ei) be the biconnected components of a connected undirected graph G = (V, E). Then (1) Gi is biconnected for each 1 i k , (2) For all i j , Vi Vj contains at most one vertex. (3) a is an articulation point of G if and only if a Vi Vj for some ij [ proof ] (1) Trivial why ? (2) suppose that two distinct vertices v and w are in Vi  Vj , i j C1 v Gi Why? w C2 Gj v (3) x () () a y w

  6. F A A B B E E C C D D A A F B B C C D D E E A is not an articulation point A is an articulation point Can you now characterize an articulation point when A is the root ?

  7. A E B D I F C H G A B C Can you characterize D ? D E F G H I

  8. v w One or more bicomponents An articulation point v in a depth-first search tree. Every path from root to w passes through v.

  9. v' v w

  10. Theorem : Let G = (V, E) be a connected, undirected graph and let S = (V, T) be a depth first spanning tree for G. Vertex a is an articulation point of G if and only if one of the following is true: (1) a is the root and a has two or more sons. (2) a is not the root and for some son s of a, there is no back edge between any descendant of s ( including s itself ) and a proper ancestor of a.

  11. [proof] i) The root is an articulation point if and only if it has two or more sons. y x () () a y x x y

  12. (ii) () a y x Since a is not the root, either x or y is a proper descendant of a !!! why ? y a x WLOG, let x be a proper descendant of a a a s s This is not possible. Why ? x x y  Only this Two cases: (1) (2) a a no back edge back edge s s x x

  13. case (2) back edge y is not a descendant of a. y a x y is a descendant of a. w' w This is not possible. s s’ a y x () Easy, Exercise

  14. An algorithm for finding all biconnected components of a graph G = (V, E) z v w biconnected component z

  15. How to detect an articulation point ? When to report a biconnected component ? Assumption Depth First Search

  16. Depth First Search number B F C A G =(V, E) D E 1 A A B C D E F 123654 2 B 6 D 3 C 4 5 F E Any relation between DFS numbers and articulation point ?

  17. A 1 Assume that (a,b) a b Tree edge : (a,b) a < b Back edge : (a,b) a > b 2 B 6 D 3 C 4 5 F E w’ If there is a back edge from x to a proper ancestor of v, then v is reachable from x. v w x

  18. How far back in the DFS tree from each vertex ? BACK[v] v can back to BACK[v] by following (1) tree edges (2) back edges Initially, BACK[v] = v, where v is a DFS number why ? BACK[v]:= min{BACK(v), min{w| (x,w) is a back edge, x is a descendant of v, and w is an ancestor of v.} w v x

  19. What if v BACK(w), when w v (back up to v) ? assuming that BACK(w) = min{BACK(x) | xT(w)} v is an articulation point !!! why ? Now, how to update BACK(v) ? (i) vw (back edge) (ii) vw (backing up to v) case(i) BACK[v]:= min{BACK[v], w} : back edge why ? case(ii) BACK[v]:= min{BACK[v], BACK[w]} : back up to v why ? v x w w v w

  20. How to detect and when ? v when ?  ? or  ? why ? w How ? v BACK(w) !!! How to report ? Well, ……. A set of edges.

  21. r z y v b a w B W A when v is reached, pop edges until (v, w) is reached W (v, w) (y, v) A (y, a) (z, y) (r, z) Edge Stack

  22. 1 A 1/1 2 D A 10 F 2/2 J D 3 9 H 4 E 4/4 E F 5 7 B 3/1 B 5/5 G C C (b) Proceed forward ; initialize values of back ; Detect back edge FA ; update back[F] ; 6/4 8 I 6 (c) Continue forward ; Detect back edge CE ; update back[C] (a)The complete depth- first search tree. 5/4 7/5 4/4 E 4/4 5/4 7/7 G B G B B B 5/4 5/4 I 8/5 I 8/5 C C 6/4 (e) Forward to G and I ; detect back edge IB ; update back[I] ; back[I]<dfsNumber[G] (f) Back up to G updating back[G]; back[G]=dfsNumber[B] ; remove bicomponent ; (g) Back up to B ; back[B]=dfsNumber[E] ; remove bicomonent ; (d) back[C]<dfsNumber[B] so back up to B updating back[B]. The action of the bicomponent algorithm on the graph in Fig. 4.25 (detecting the first two bicomponents)

  23. procedure SEARCHB(v); begin mark v "old"; DFSNUMBER[v]  COUNT; COUNT  COUNT + 1; BACK[v]  DFSNUMBER[v]; for each vertex w on L[v] do Stack edges, here if w is marked "new" then begin add(v, w) to T; FATHER[w] v SEARCHB(w) if BACK[w]  DFSNUMBER[v] then a biconnected component has been found ; Pop, here BACK[v]  MIN(BACK[v], BACK[w]) end else if w is not FATHER[v] then BACK[v]  MIN(BACK[v], DFSNUMBER[w]) end O(|Ei|) Report O(|Ei|) why ?

  24. Algorithm : Bicomp. T := Ø ; for all v in V do mark v as "new" end for all "new" vertex v in V do count := 1 ; SEARCHB(v) |V| + (|E1| + |E2| + …) = |V| + |E| end Theorem : Algorithm Bicomp correctly finds the biconnected components of G = (V, E) in O(|E| + |V|) time. [proof ] See the next page. O(|V|)

  25. (i) Time complexity O(|V| + |E|) (ii) Correctness Root ?  Even if the root is not an articulation point, it can be treated as an articulation point !!! why ? The biconnected component containing the root is emitted from the root.

  26. (By induction on the # of biconnected components in G ) Reporting a biconnected component (i) w v (SEARCHB(w) is completed) (ii) v  BACK(w) v w The edges above (v, w) on STACK is exactly those edges in the biconnected component containing (v, w). (b = 1) Trivial why ? Depth First Search !!! In this case, v must be the root !!! why ? (b = i) Assume the induction hypothesis. (b = i+1) (v,w)  b-1=i

  27. K-connectivity k = 1 connectivity k = 2 bi-connectivity k = 3 tri-connectivity k = 4 no known efficient algorithm

  28. 6. Strongly Connected Components of a Digraph Def'n : Let G = (V, E) be a directed graph. We can partition V into equivalent classes Vi, 1i r, such that vertices v and w are equivalent if and only if there is a path from v to w and w to v. Let Ei, 1i r, be the set of edges connecting the pairs of vertices in Vi. The graph Gi = (Vi, Ei) are called the strongly connected components of G. A graph is said to be strongly connected if it has only one strongly connected component. G1 1 2 3 G3 G=(V, E) 8 9 7 4 5 6 G2

  29. A A B H B H E D E D F G C F G C J I J I K K (a) A digraph (b) Its strong components. The condensation of the digraph

  30. G = (V, E) A Weakly Connected Component

  31. How to find the strongly connected components of a graph ? Assumption : Depth First Search tree edge descendant edge cross edge back edge

  32. v1 v9 v12 v5 G = (V, E) v2 v4 v13 v11 v10 v3 v6 v16 v14 v15 v7 v8 v17 v18 v1 13 v13 1 T = (V, ET) v2 v14 2 14 15 v15 v3 3 16 v16 4 v4 9 v10 18 v6 17 v17 v18 6 5 v5 10 v12 v7 12 7 v11 11 v9 8 v8 Spanning Forest

  33. Lemma : Let Gi= (Vi, Ei) be a strongly connected component of a directed graph G = (V, E). Let T = (V, ET) be a depth-first search spanning forest of G. Then the vertices of Gi together with the edges which are common to both Ei and ET form a subtree of the spanning tree T. [ proof ] v,w  Vi v w Depth first number Gi=(Vi, Ei) WLOG, let v < w. In Gi, P v w why ? x = min{ y| y is in P } Note : x may be v itself. In T, x Once P reaches a descendant of x in T, it cannot leave the subtree of x !!! why? p

  34.  w is a descendant of x !!! why ? Now, all vertices between x and w are also descendants of x. why ? DFS !!! ( by the way of T is connected ) Since x v < w, v is also a descendant of x.  Any pair of vertices in Gihave a common ancestor in T. This is also in Gi. why ?  r min{ y| y is a common ancestor of the vertices in Gi} u Gi why?

  35. (r1, r2,····, rk) Observation i < j Either riis to the left of rj ora descendant of rj. why ?

  36. v1 v6 v9 v3 G = (V, E) v2 v7 v8 v4 v5 v1 1 v2 2 v3 3 6 v6 4 v4 v9 v7 9 7 v5 5 v8 strongly connected components 8 (r1, r2, r3, ····, rk)  the sequence of roots in the order in which 4 6 1 the DFS of these vertices are terminated.

  37. Lemma : For each i, 1 i k, Gi consists of those vertices which are descendant of ri but are in none of G1, G2,····, Gi-1. [proof] The root rj for j > i cannot be a descendant of ri, since the call of SEARCH(rj) terminates after SEARCH(ri).

  38. r w w v or LOWLINK[v] = min { {v}  { w| there is a cross or back edge from a descendant of v to w, and the root of the strongly connected component containing w is an ancestor of v} } LOWLINK[v] v Why ?

  39. Lemma : Let G = (V, E) be a directed graph. A vertex v is the root of a strongly connected component if and only if LOWLINK[v] = v. [proof] (  ) Suppose that v is the root of a strongly connected component of G. By definition of LOWLINK, LOWLINK[v] v for all vV. why ? Suppose that LOWLINK[v] < v. Then, there are vertices w and r such that [1] w is reached by a cross or back edge from a descendant of v. [2] r is the root of the strongly connected component containing w. [3] r is an ancestor of v. [4] w < v (2)  r is an ancestor of wr w (2),(4)  r w < v r < v (3)  r is a proper ancestor of v. r and v must be in the same strongly connected component !!! why ? v is not the root of a strongly connected component. #  LOWLINK[v] = v. r w w v r v

  40. (  ) Now, suppose that LOWLINK[v] = v. Assume that v is not the root of the strongly connected component containing v. Then, there is some proper ancestor r of v, which is the root, i.e., r Then , there is a path P from v to r . Why? Consider the first edge of P from a descendant of v to a vertex w that is not a descendant of v. w<v Why? w v P P w The path P goes from v to w to r. Why? There also exists a path from r to v. Why? r and w are in the same strongly connected component. LOWLINK[v] w < v. #

  41. How to compute LOWLINK[v] v LOWLINK[v] := v LOWLINK[v] = min{ w, LOWLINK[v] } LOWLINK[v] = min{ LOWLINK[w], LOWLINK[v] } w v v w w v w

  42. How to report Gi x y v w LOWLINK[w] = w g g w v y x

  43. Procedure SEARCHC(v): begin mark v "old"; DFSNUMBER[v] COUNT; COUNTCOUNT + 1; O(|V|) LOWLINK[v]  DFSNUMBER[v]; push v on STACK; for each vertex w on L[v] do O(|E|) if w is marked "new" then begin SEARCHC(w); LOWLINK[v]  MIN(LOWLINK[v], LOWLINK[w]) end back edge or cross edge else {not new} if DFSNUMBER[w] < DFSNUMBER[v]need a table and w is on STACK then LOWLINK[v]  MIN(DFSNUMBER[w], LOWLINK[v]) if LOWLINK[v] = DFSNUMBER[v] then begin repeat begin pop x from top of STACK; print x end until x=v; print "end of strongly connected component" end end

  44. Algorithm : (Strongly connected components of a directed graph) procedure StrongCC begin count := 1; for all v in V do mark v "new" O(|V|) end STACK := Ø while there exists a vertex v marked "new" do SEARCHC(v) O(|E|) end. end Optimal !!! O( |V| + |E| )

  45. Theorem : "StrongCC" correctly finds the strongly connected components of G in O(|V| + |E|) time. [proof] Time complexity : Already shown correctness : ( By induction on # of calls to SEARCHC) "Whenever SEARCHC terminates, LOWLINK(v)is correctly computed." Exercise.

More Related