5. biconnected components of a graph
Post on 05-Jan-2016
97 Views
Preview:
DESCRIPTION
TRANSCRIPT
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 froma connected graph, is the remaining subgraph still connected?
GI
E
C
F
B
A D
H J F
A D
H J
E
F
E
CB
GI
B
(a) graph. (b) Its biconnected components
Def’n: Let G=(V, E) be a connected, undirected graph. A vertex aV 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
Def’n: A graph G =(V, E) is said to be biconnected if and only if it has no articulation points.
G1
G2 G3
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 !!!
Observation
G = (V, E)
Two edge e1 and 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) R why ?
Each subgraph consisting of the edges in an equivalent class and
the incident vertex is a biconnected component !!!
Can you prove it ?
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
v
w
C1
Gi
Gj
C2
Why?
(3) x
a
y
() ()x
a
y
v
w
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 anarticulation point when A is the root ?
A
B
C
D
E
F
GH
I
A
B
C
D
EF
G
H
I
Can you characterize D ?
An articulation point v in a depth-first search tree.Every path from root to w passes through v.
v
w
One or morebicomponents
w
v'
v
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.
[proof] i) The root is an articulation point if and only if it has two or more sons.
()
()
x y
x ya
yx
(ii)()
x ya
yx
Since a is not the root, either x or y is a proper descendant of a !!!
awhy ?
WLOG, let x be a proper descendant of a a
x x y
s
a
sThis is not possible.Why ?
Only this
Two cases: (1) (2)
x
a
x
ass
back edgeno back edge
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.s s’
v
w
z
An algorithm for finding all biconnected components of a graph G = (V, E)
biconnected component
z
How to detect an articulation point ?
When to report a biconnected component ?
Assumption
Depth First Search
Depth First Search number
B
D E
A C FG =(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
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 xto a proper ancestor of v,then v is reachable from x.
6
w
x
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
What if v BACK(w), when w v (back up to v) ?
assuming that BACK(w) = min{BACK(x) | xT(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
How to detect and when ?
v
wwhen ?
? or ?
why ?
How ? v BACK(w) !!!
How to report ? Well, ……. A set of edges.
v
w
z
WAB
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
A
D
F
E
B
C
JH
G
I
1
2
345
68
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/4B
5/4 7/7
8/5
G
I
B5/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
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(|Ei|)
Report
O(|Ei|)why ?
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|)
(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.
( 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 thoseedges 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
K-connectivity
k = 1 connectivity
k = 2 bi-connectivity
k = 3 tri-connectivity
k = 4
no known efficient algorithm
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.
1
2 3
4
56
7
89
G=(V, E)
G1
G2
G3
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
G = (V, E)
A Weakly Connected Component
How to find the strongly connected components of a graph ?
Assumption : Depth First Search
tree edgedescendant edgecross edgeback edge
v1
v8v7
v6
v4
v3
v2
v5
v10
v9 v12
v11
v15v14
v13
v18v17
v16
G = (V, E)
v5
v6
v11
v4
v1
v2
v3
v7
v8
v16
v17
T = (V, ET)
v18
Spanning Forest
v10
v12
v9
v13
v14
v15
1
2
3
4
5 6
78
9
10
1112
13
14
1516
17 18
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 ]
Gi =(Vi, Ei)
v,w Vi
Depth first number
WLOG, let v < w.In Gi,
v wP
why ?
x = min{ y| y is in P }
Note : x may be v itself. In T,
p
xOnce P reaches a descendant of x in T,it cannot leave the subtree of x !!! why?
v w
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 Gi have 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?
iGu ' Turu in )~('
iGur, r u
'u
(r1, r2,····, rk)
Observation
i < j Either ri is to the left of rj or a descendant of rj. why ?
v4 v5
v7
v6 v9
v8
v1
v2
v3
G = (V, E)
v5
v4
v1
v2
v3
1
2
3
4
5
v6
v7
v8
6
7
8
v9 9
(r1, r2, r3, ····, rk) the sequence of roots in the order in which 4 6 1 the DFS of these vertices are terminated.
strongly connected components
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).
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
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
rw
( ) 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<vWhy?
w
PP
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
How to report Gi
w LOWLINK[w] = w
xyv
g
x
y
v
gw
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" endend
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| )
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.
top related