Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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 E C F B A D H J F A D H J E F E C B G I B (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. G1G1 G2G2 G3G3 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 e 1 and e 2 in E is said to be related if e 1 = e 2 or if there is a cycle containing both e 1 and e 2. (e, e)  R  e  E (e 1, e 2 )  R and (e 2, e 3 )  R  (e 1, e 3 )  R (e 1, e 2 )  R  (e 2, e 1 )  R why ? Each subgraph consisting of the edges in an equivalent class and the incident vertex is a biconnected component !!! Can you prove it ?

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

6 A B C D E A B C D E F A B C D E A B C D E F 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 B C D E F G H I A B C D E F G H I Can you characterize D ?

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

9 w v' v

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. ()() ()() x y x y a yx

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

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

14 v w z An algorithm for finding all biconnected components of a graph G = (V, E) 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 D E A C F G =(V, E) B D E A C F Any relation between DFS numbers and articulation point ? 1 2 3 4 5 A B C D E F 1 2 3 6 5 4 6

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

18 How far back in the DFS tree from each vertex ? v w 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.} 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) v w (back edge) (ii) v w (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 ? w v v w x w

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

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

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

23 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 procedure SEARCHB(v); O(|E i |) Report O(|E i |) 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) The edges above (v, w) on STACK is exactly those edges in the biconnected component containing (v, w). 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 V i, 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 E i, 1  i  r, be the set of edges connecting the pairs of vertices in V i. The graph G i = (V i, E i ) are called the strongly connected components of G. A graph is said to be strongly connected if it has only one strongly connected component. 1 2 3 4 5 6 7 8 9 G=(V, E) G1G1 G2G2 G3G3

29 A D F E B C J H G I K A D F E B C J H G I 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 v1v1 v8v8 v7v7 v6v6 v4v4 v3v3 v2v2 v5v5 v 10 v9v9 v 12 v 11 v 15 v 14 v 13 v 18 v 17 v 16 G = (V, E) v5v5 v6v6 v 11 v4v4 v1v1 v2v2 v3v3 v7v7 v8v8 v 16 v 17 T = (V, E T ) v 18 Spanning Forest v 10 v 12 v9v9 v 13 v 14 v 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

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

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 G i have a common ancestor in T. This is also in G i. why ?  r  min{ y| y is a common ancestor of the vertices in G i } u  G i  why?

35 (r 1, r 2,····, r k ) Observation i < j  Either r i is to the left of r j or a descendant of r j. why ?

36 v4v4 v5v5 v7v7 v6v6 v9v9 v8v8 v1v1 v2v2 v3v3 G = (V, E) v5v5 v4v4 v1v1 v2v2 v3v3 1 2 3 4 5 v6v6 v7v7 v8v8 6 7 8 v9v9 9 (r 1, r 2, r 3, ····, r k )  the sequence of roots in the order in which 4 6 1 the DFS of these vertices are terminated. strongly connected components

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

38 w v r 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 ? w

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 v w v r w

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., 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. # v r w 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 P P

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

42 How to report G i w LOWLINK[w] = w x y v g x y v g w

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

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.


Download ppt "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."

Similar presentations


Ads by Google