connectivity and biconnectivity
play

Connectivity and Biconnectivity 462 cec CS 16: Connectivity - PDF document

CS 16: Connectivity Connectivity and Biconnectivity 462 cec CS 16: Connectivity Connected Components Connected Graph : any two vertices connected by a path connected not connected Connected Component : maximal connected subgraph of a


  1. CS 16: Connectivity Connectivity and Biconnectivity 462 cec

  2. CS 16: Connectivity Connected Components Connected Graph : any two vertices connected by a path connected not connected Connected Component : maximal connected subgraph of a graph 463 cec

  3. CS 16: Connectivity Equivalence Relations A relation on a set S is a set R of ordered pairs of elements of S defined by some property Example: • S = {1,2,3,4} • R = {(i,j) ∈ S × S such that i < j} = {(1,2),(1,3),(1,4),(2,3),(2,4),{3,4)} An equivalence relation is a relation with the following properties: • (x,x) ∈ R, ∀ x ∈ S ( reflexive ) • (x,y) ∈ R ⇒ (y,x) ∈ R ( symmetric ) • (x,y), (y,z) ∈ R ⇒ (x,z) ∈ R ( transitive ) The relation C on the set of vertices of a graph: • ( u , v ) ∈ C ⇔ u and v are in the same connected component is an equivalence relation. 464 cec

  4. CS 16: Connectivity DFS on a Disconnected Graph 2 3 3 1 5 5 6 6 4 7 After dfs(1) terminates: k 1 2 3 4 5 6 7 val[k] 1 4 0 2 0 0 3 4 0 1 2 3 3 1 0 2 3 0 5 5 6 6 4 7 465 cec

  5. CS 16: Connectivity DFS of a Disconnected Graph • Recursive DFS procedure visits all vertices of a connected component. • A for loop is added to visit all the graph for all k from 1 to N if val[k] = 0 dfs(k) 2 3 1 4 7 6 5 466 cec

  6. CS 16: Connectivity Representing Connected Components Array comp [1..N] comp[k] = i if vertex k is in i-th connectedcomponent 4 3 1 6 5 8 2 7 2 3 1 vertex k 1 2 3 4 5 6 7 8 comp[k] 1 1 2 3 2 3 2 1 467 cec

  7. CS 16: Connectivity New DFS Algorithm Inside DFS: id = id + 1; replace val [k] = id ; comp[k] = id ; with Outside DFS: for all k from 1 to N for each vertex if comp [k] = 0 if not in comp id = id + 1; new component dfs(k); 468 cec

  8. CS 16: Connectivity DFS Algorithm for Connected Components Pseudocoded dfs (int k); comp[k] = vertex.id; vertex = adj[k]; Vertex vertex while (vertex != null) if (val[vertex.num] == 0) dfs (vertex.num); vertex = vertex.next; . . . for all k from 1 to N if (comp[k] == 0) id = id + 1; dfs (k); TIME COMPLEXITY: O (N + M) 469 cec

  9. CS 16: Connectivity Cutvertices Cutvertex (separation vertex): its removal disconnects the graph If the Chicago airport is closed, then there is no way to get from Providence to beautiful Denver, Colorado! SEA MSN PVD ORD SFO DEN LGA STL LAX LAX ATL DFW MIA • Cutvertex: ORD 470 cec

  10. CS 16: Connectivity Biconnectivity Biconnected graph: has no cutvertices SEA MSN PVD ORD SFO DEN LGA STL LAX LAX ATL DFW MIA New flights: LGA-ATL and DFW-LAX make the graph biconnected. 471 cec

  11. CS 16: Connectivity Properties of Biconnected Graphs SEA MSN PVD ORD SFO DEN LGA STL LAX LAX ATL DFW MIA • There are two disjoint paths between any two vertices. • There is a simple cycle through any two vertices. By convention, two nodes connected by an edge form a biconnected graph, but this does not verify the above properties. 472 cec

  12. CS 16: Connectivity Biconnected Components Biconnected component (block): maximal biconnected subgraph SEA MSN PVD SFO ORD DEN LGA STL LAX LAX ATL DFW MIA Biconnected components are edge-disjoint but share cutvertices. 473 cec

  13. CS 16: Connectivity Finding Cutvertices: Brute Force Algorithm for each vertex v remove v; test resulting graph for connectivity; put back v; Time Complexity: • N connectivity tests • each taking time O ( N + M ) Total time: • O ( N 2 + NM ) 474 cec

  14. CS 16: Connectivity DFS Numbering We recall that depth-first-search partitions the edges into tree edges and back edges • (u,v) tree edge ⇔ val [u] < val [v] • (u,v) back edge ⇔ val[u] > val[v] 1 A 2 F C B 7 6 E 3 D 4 G 5 We shall characterize cutvertices using the DFS numbering and two properties ... 475 cec

  15. CS 16: Connectivity Root Property The root of the DFS tree is a cutvertex if it has two or more outgoing tree edges. • no cross/horizontal edges • must retrace back up • stays within subtree to root, must go through root to other subtree root 476 cec

  16. CS 16: Connectivity Complicated Property A vertex v which is not the root of the DFS tree is a cutvertex if v has a child w such that no back edge starting in the subtree of w reaches an ancestor of v. root root v w 477 cec

  17. CS 16: Connectivity Definitions • low ( v ): vertex with the lowest val (i.e., “highest” in the DFS tree) reachable from v by using a directed path that uses at most one back edge • Min ( v ) = val ( low ( v )) v low( v ) Min( v ) 1 ________________ A A A 1 2 B A 1 B C B 2 3 C F D B 2 6 E B 2 D E F A 1 4 5 478 cec

  18. CS 16: Connectivity DFS Algorithm for Finding Cutvertices 1. Perform DFS on the graph 2. Test if root of DFS tree has two or more tree edges ( root property ) 3. For each other vertex v , test if there is a tree edge ( v , w ) such that Min( w ) ≥ val[ v ] ( complicated property ) Min(v) = val(low(v)) is the minimum of: • val[v] • minimum of Min(w) for all tree edges (v,w) • minimum of val[z] for all back edges (v,z) Implement this recursively and you are done!!!! 479 cec

  19. CS 16: Connectivity Finding the Biconnected Components • DFS visits the vertices and edges of each biconnected component consecutively • Use a stack to keep track of the bicon- nected component currently being tra- versed 480 cec

  20. CS 16: Connectivity MSN ORD PVD SEA LGA SFO DEN LAX LAX STL ATL LAX SAN DFW MIA SJU STT 481 cec

Recommend


More recommend