Finding two vertex connected components in linear time

Similar documents
We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:

Graph Algorithms Using Depth First Search

MAL 376: Graph Algorithms I Semester Lecture 1: July 24

Lecture 3: Graphs and flows

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Treewidth and graph minors

Graph Algorithms. Definition

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Cut vertices, Cut Edges and Biconnected components. MTL776 Graph algorithms

MATH 409 LECTURE 10 DIJKSTRA S ALGORITHM FOR SHORTEST PATHS

In this lecture, we ll look at applications of duality to three problems:

22.3 Depth First Search

Parameterized coloring problems on chordal graphs

Problem Set 2 Solutions

Module 5 Graph Algorithms

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

HW Graph Theory SOLUTIONS (hbovik) - Q

CMSC th Lecture: Graph Theory: Trees.

Discrete mathematics

Introduction to Computers and Programming. Concept Question

Lecture 20 : Trees DRAFT

(Refer Slide Time: 02.06)

K 4 C 5. Figure 4.5: Some well known family of graphs

Chapter 11: Graphs and Trees. March 23, 2008

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Binary Heaps in Dynamic Arrays

Finding k-paths in Cycle Free Graphs

(Refer Slide Time: 06:01)

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

Searching in Graphs (cut points)

March 20/2003 Jayakanth Srinivasan,

Flow Graph Theory. Depth-First Ordering Efficiency of Iterative Algorithms Reducible Flow Graphs

ifn >-- 2 is even, ifn is odd, ifn =0,

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES

6. Finding Efficient Compressions; Huffman and Hu-Tucker

Graph Algorithms. Imran Rashid. Jan 16, University of Washington

15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017

Lecture 14: March 9, 2015

CS24 Week 8 Lecture 1

{ 1} Definitions. 10. Extremal graph theory. Problem definition Paths and cycles Complete subgraphs

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.

Fully dynamic algorithm for recognition and modular decomposition of permutation graphs

Recoloring k-degenerate graphs

Algorithmic Aspects of Communication Networks

Trees Algorhyme by Radia Perlman

On 2-Subcolourings of Chordal Graphs

st-orientations September 29, 2005

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND

Trees. Arash Rafiey. 20 October, 2015

Outline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black.

LECTURE 11 TREE TRAVERSALS

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES

Chapter 15. Binary Search Trees (BSTs) Preliminaries

We assume uniform hashing (UH):

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

DOUBLE DOMINATION CRITICAL AND STABLE GRAPHS UPON VERTEX REMOVAL 1

Depth-First Search Depth-first search (DFS) is another way to traverse the graph.

MATH20902: Discrete Maths, Solutions to Problem Set 1. These solutions, as well as the corresponding problems, are available at

Search Trees. Undirected graph Directed graph Tree Binary search tree

Randomized incremental construction. Trapezoidal decomposition: Special sampling idea: Sample all except one item

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

1 Variations of the Traveling Salesman Problem

CS 310 Advanced Data Structures and Algorithms

1 Maximum Independent Set

An O(m + nlog n) On-Line Algorithm for Recognizing Interval Graphs

1 Leaffix Scan, Rootfix Scan, Tree Size, and Depth

Binary Search Trees. Carlos Moreno uwaterloo.ca EIT

Matching Theory. Figure 1: Is this graph bipartite?

Notes on Binary Dumbbell Trees

Binary Trees

Scribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017

Trapezoidal decomposition:

An eccentric coloring of trees

13.4 Deletion in red-black trees

Lecture 10: Strongly Connected Components, Biconnected Graphs

Section 3.1: Nonseparable Graphs Cut vertex of a connected graph G: A vertex x G such that G x is not connected. Theorem 3.1, p. 57: Every connected

Non-context-Free Languages. CS215, Lecture 5 c

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

6. Finding Efficient Compressions; Huffman and Hu-Tucker Algorithms

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

Exact Top-k Nearest Keyword Search in Large Networks

13.4 Deletion in red-black trees

arxiv: v1 [cs.cg] 15 Jan 2015

Dominance Constraints and Dominance Graphs

6.854J / J Advanced Algorithms Fall 2008

Definition of Graphs and Trees. Representation of Trees.

Classic Graph Theory Problems

CE 221 Data Structures and Algorithms

Math 777 Graph Theory, Spring, 2006 Lecture Note 1 Planar graphs Week 1 Weak 2

Applications of BDF and DFS

Minimum spanning trees

Broadcast: Befo re 1

Rainbow game domination subdivision number of a graph

The priority is indicated by a number, the lower the number - the higher the priority.

COMP 251 Winter 2017 Online quizzes with answers

CSE 530A. B+ Trees. Washington University Fall 2013

Transcription:

TO 1 Finding two vertex connected components in linear time Guy Kortsarz

TO 2 ackward edges Please read the DFS algorithm (its in the lecture notes). The DFS gives a tree. The edges on the tree are called tree edges. The rest are called backward edges. ackward edges must go from a vertex to its ancestor. Indeed what if there is a side edge a b and say that we got to a before b, Since b is unvisited (it came after a) we should have recursed with b. ut we backtracked, which is a contradiction. e prove a claim: laim: Every graph G(V,E) has a tree T(V,E ) so that every edge in E E is a backward edge.

TO 3 n example of a DFS run k=1 D E F G k=13. K=12 Y X k=2 D k=3 k=4 H Z E k=5 X J K F k=6 Y G k=7 k 8 H k=9 J k=11 K k=10 Figure 1: n example of a DFS ran

TO 4 The order of traversal of edges First, then (ignored), then D, then D, (backward edge. be for short) D, (be),, E, E (be) E (be), E, (ignored) EF, FE (ignored), FG, GH HE (be), HF (be), HG (ignored) HJ, JK, KH (be) KJ (ignored). acktrack to H, HZ, ZH (ignored) backtrack to. X X (ignored) XY, Y (be) YX (ignored) backtrack to. Finish.

TO 5 nother example E D F Y w P x S Z Q R Figure 2: Run DFS. Say the order we go over edges

TO 6 The tree E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 3: DFS run

TO 7 Order of the edges, (ignored),, (be) (ignored) D, D (be), D (be) D (ignored) DF, FE E, F (be) acktrack to D. DP, PQ (ignored), QP (ignored) QR, RS, SR (ignored) SQ (be), backtrack to D. DX, XD (ignored) XY, YE, Y (ignored), Z, Z (ignored) ZY (be) acktrack to. Finish.

TO 8 Long paths e show using DFS that any graph has a path of length at least m/n. If m = n 2 /20 for example this gives n/20 length path. Very long To find such a path just take any DFS tree and take the height. e now upper bound the number of edges as a function of the height. ecause all edges are backward edges n h m. This only happens with leaves of level h that have all edges to their ancestors. This implies that h m/n

TO 9 Separating vertices These are vertices whose removal disconnects the graph. E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 4: The Run of DFS Separating vertices here: {D,X,Y,P,Q}.

TO 10 trivial and slow algorithm to find all separating vertices Note we assume from now on that the graph is connected as otherwise it makes no sense e can go over all vertices and for each vertex remove it and all its edges. This means that the linked lists change. If we are now at vertex v look at G v. Do a SF from any s G v. If one of the distances is infinite v is a separating vertex. ut this taken O(n(n+m)). Thus is not linear in n and m. Our next task is to give an algorithm that finds all separating vertices in O(m+n)

TO 11 n algorithm to find all separating vertices Definition: separating vertex in a connected graph is a vertex whose deletion together with its edges, makes the graph disconnected. It is quite convenient that a vertex has only up edges. Let T v be the subtree rooted at v. Let p(v) be the parent of v. Not having side edges means that a vertex v can go to or above his parent only by going down to a descendant and using an up edge that goes above his parent. This is illustrated in the next slide by a figure.

TO 12 separating vertex U, UX, XM M M M M X X U E Y UY YE E EY MX FZ FU E XU U UD UY YU YE UZ ZU ZF 1 U U E X D Y Z 2 U X M M U X X 3 Y 9 Z 11 M M X M 4 7 8 10 D E F 12 U X 5 6 D X U Y U E Z U F F Z U Figure 5: X is not a separating vertex. ecause it does not separate his three children from their grandparent. M can go down to and then to the root (thus if X is taken out M can reach its grandparent of X by going to the root and going down to U. has a backward edge above X, and so does D. However U is a separating vertex because Z can not go down T z and jump above U

TO 13 Low number of a vertex How close to the root can a vertex get? hat is the minimum k(v) that a vertex u can reach using at most one back edge? It may be that back edges do not help and the lowest k value that u can get to is k(u). It may be that u has back edges. The back edge that goes highest is a candidate for the low number. lso lets think of vertices on descendants of v have backward edges. Trampolines as I call it. Go down to the best trampoline and jump once.

TO 14 The definition of L(u) L(u) is the the vertex with least k value that a vertex can reach without using its parent. There are 3 ways to get lower L(P). 1. k(u) (meaning stay put). It is always true that L(P) k(p) 2. If a vertex has backward edges go out of u we can choose the L(u) to be the minimum k value. 3. U can go down to some T Q with Q a child of P and use one backward edge inside T Q. The least number it can get bounds L(P) from above

TO 15 Example U, UX, XM M M M M X X U E Y UY YE E EY MX FZ FU E XU U UD UY YU YE UZ ZU ZF 1 U U E X D Y Z 2 U X M M U X X 3 Y 9 Z 11 M M X M 4 7 8 10 D E F 12 U X 5 6 D X U Y U E Z U F F Z U Figure 6: L() = 1 by rule 1. L(U) = 1 by going down to and jumping (rule 3). L(X) = 1 by rule 3. L(Y) = 1 by rule 3. L(Z) = 2 by rule 3. L(M) = 1 by rule 3. L() = 2 by rule 2. L(D) = 2 by rule 2. L(E) = 1 by rule 2. L(F) = 2 by rule 2. L() = 1 by rule 2. L() = 3 by rule 2.

TO 16 theorem vertex u is a separator vertex if and only if for every child v, low(v) < k(v). Namely if every child can reach the grandparent. Note that the grand parent can reach the root even if par(u) is remove and so can all other vertices. For example a vertex in T v a tree rooted by a child v of u has a path to par(par(u)) and so to the root, if par(u) is deleted.

TO 17 The inequality that implies a separating vertex Let v be the child of u with u not the root. If L(v) k(u) it means that v can not jump over his parent u. Thus the removal of u disconnects v from par(u). laim: a vertex u is separating if and only if for some child v of u, L(v) k(u). If this holds than after u is remove v and p(u) have no path in G u.

TO 18 The root will always be considered a separating vertex However the root is a separating vertex, if and only if it has at least two children. This is because up edges do not exist. If it has one child, clearly the removal of the root leaves a single connected component. If it has two children or more then as there are no side edges, the two children will become disconnected. For the purpose of finding 2 vertex connected components (later) its good to treat the root as a separating vertex

TO 19 Thinking on it as a recursive algorithm Let U ve a vertex and V 1,V 2,...,V k children of U. learly L(U) min{l(v 1 ),L(V 2 ),...,L(V k )} if z is a child of u then L(u) L(z). Think recursively. hen we get back to a child of Z, of U we know the low number of the child L(Z). Then we can set L(U) min{l(u),l(z)}. Second, when we discover a backward edge say UZ, then L(U) min{l(u),k(z)}. Read the algorithm for finding separating vertices (in the slide notes).

TO 20 Finding separating vertices E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 7: Finding separating vertices

TO 21 The run of the algorithm L() 1, L() 2, L() 3, L() 1, L(D) 4 L(D) 1 L(F) 5. L(E) 6, L(E) 4 L() 7 L() 5, acktrack L() < k(e). L(E) < k(f) L(F) k(d). D separator. L(P) 8, L(Q) 9, L(R) 10, L(S) 11. L(S) 9 acktrack L(R) 9. L(S) < k(r). acktrack. L(R) k(p), P is separating. L(P) > k(d),d is separator. L(X) 12. L(Y) 13, L() 14, L(Z) 15, L(Z) 13. L() 15 L(Z) < k(y). acktrack. L() 13. L() k(y), Y is separating. L(Y) k(x), X is sep. L(D) < k(), L() < k(). not separating.

TO 22 2 vertex connected components graph is vertex two connected if for every two vertices v,u in the graph there are at least two paths between u and v. nother way to say that a graph is two vertex connected is saying that graph has no separating vertices. If a graph is not two vertex connected a 2 connected component is a maximum size subgraph that is two vertex connected. 2 vertex connected component is also called a (bio connected component) if 1. The subgraph is two vertex connected and 2. The subgraph is not contained in a larger

TO 23 Examples In trees the are every edge (note that a vertex alone is never a ). Figure 8: The of a graph, example

TO 24 The theory of the laim: The size of the intersection over vertices of two is at most one. Namely the following is not possible. Figure 9: Two can not have intersection of size 2

TO 25 proof e show that if we remove, is still connected. similar proof holds for and an easier proof follows for removing any vertex that is not or. onsider alone, disregarding. This is a and in partial it it two vertex connected. Thus removing leaves a connecting graph. In the same way disregarding, removing from leaves a connected graph. Let 1 =, 2 =. e know that 1. 1 and 2 are connected. 2. They share a vertex and so 1 2 is connected. 3. ut this means that is a that contains both and. 4. This is a contradiction

TO 26 The unique intersecting vertex onsider the graph induced by. say that they intersect at a. See the following figure Figure 10: Two that intersect on a

TO 27 Proof oth X, X for X a can reach a as, are. If we remove a by the assumption toward a contradiction the graph remain connected. Thus is a two vertex connected subgraph, which is a contradiction

TO 28 a cycle of cant exist e define a path 1, 2, 3... on. The path is legal in i, i+1 intersect on separating vertex. Here is an example of a path of. 2 1 3 Figure 11: n example

TO 29 cycle can not exists G F E D Figure 12: This structure cant exist

TO 30 hy not? onsider the following example. 1 2 8 J 3 7 H F D 4 6 5 Figure 13: This cant be

TO 31 Proof Say that is removed, separating 1 and 2. However by the definition of a, every vertex in 1 can reach J, then H, then F, then D then, Then which means that 1 can reach any vertex of 2. Thus the entire cycle in vertex 2-connected, contradiction.

TO 32 leaf component Let P be a longest path in a graphs. Let, be the two at the start and end of the path. The, can not intersect a that is outside as this will imply that the path is not longest. The can not intersect anyone in the middle of the path as otherwise we get a cycle of. Thus both, intersect one. y the claims above it contains one separating vertex. alled a leaf component. Theorem: There are always at least 2 with a single separating vertices. Remark: Most have much more than be separating vertex.

TO 33 high level of a run 6 E E 5 D D 4 3 2 1 Figure 14: Moving via non leaf until we get to a leaf

TO 34 Intuition for finding onsider an edge eating monster. He eats an edge and also pushes it to a STK. It starts at some 1. Unfortunately, it may leave 1 to 2 2 before it eats (puts on the stack) all the edges of 1. Now, since 1 has more than one separating vertex the monster can get out of 1 before it eats all the edges of 1. It goes out by another separating vertex. The same hold true for 2, 3, 4, 5.

TO 35 ontinued hat we have on the stack is a completely mixed collection of edges. How do we find a? ut it must eventually reach a leaf components, 6. 6 has one separating vertex. Think of separating vertices as out points. If you have one end point, (one separating vertex) you will eat all the edges before you backtrack. t this moment all the edges of all the leaf are on the top of the stack. The deep most edge in the Stack (hence the one to go out first is U V that enters the and means that U is a separating vertex. e will discover at that stage that L(F) k(e) thus we found a separating vertex. nd since we backtracked, Finding a separating vertex implies we also found a leaf component.

TO 36 hat do we know Say that E separates F. So EF was the first edge (and also first edge in the stack) among the edges of 6. e know that we backtrack, so the 6 must be a leaf (if there are two separating vertices we will leave the when we get to the second separating vertex). It may not have been a leaf at start but its a leaf now. This does not mix edges of 6 with the edges of any because we backtracked.

TO 37 ontinued It very simple to find the. Each time you find a separating vertex it means that you did backtracking, and so the of this vertex is a leaf component. If you enter the component with XY XY will be the first in the stack. edge in the because we used a stack. s soon as we find the X is a separating vertex for Y, remove all the edges until XY including. Declare that the next. e now go over the algorithm and later see an example. Think why it is good that the root is always considered a separating vertex

TO 38 n example of a run of the algorithm E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 15: The Run of DFS

TO 39 The run {(,),(,),(,),(,D),(D,),(D,), (D,F),(F,E),(E,D),(E,),(,F)} acktrack, D separating F, Take all edges till (D,F) {(D,F),(F,E),(E,D))(E,),(,F)} First. {(),(,),(,),(,D),(D,),(D,), (D,P)(P,Q),(Q,R),(R,S)),(S,Q)}. Q separate R. ll edges till (Q,R). {(Q,R),(R,S),(S,Q)} are the next.

TO 40 ontinued {(),(,),(,),(,D),(D,),(D,), (D,X),(X,Y)(Y,),(.Z),(Z,Y)}. Y separates. Next {(Y,),(,Z),(Z,Y)} {(,),(,),(,),(,D),(D,), (D,X)(X,Y)} X separates Y, thus {(X.Y)} the next. D separates X and so {(D,X)}, next. ack to, {(),(,),(,),(,D),(D,),(D,)}. ll the edges, last. ecause considered a separating vertex.