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

connectivity and biconnectivity
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CS 16: Connectivity cec

462

Connectivity and Biconnectivity

slide-2
SLIDE 2

CS 16: Connectivity cec

463

Connected Components Connected Graph: any two vertices connected by a path

connected not connected

Connected Component: maximal connected subgraph of a graph

slide-3
SLIDE 3

CS 16: Connectivity cec

464

Equivalence Relations

A relation on a set S is a set R of ordered pairs

  • f 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.

slide-4
SLIDE 4

CS 16: Connectivity cec

465

DFS on a Disconnected Graph

1 2 4 7 After dfs(1) terminates: k 1 2 3 4 5 6 7 val[k] 1 4 0 2 0 0 3 3 6 5 3 6 5 1 2 4 7 3 6 5 3 6 5 1 4 2 3

slide-5
SLIDE 5

CS 16: Connectivity cec

466

3 6 5 1 2 4 7

DFS of a Disconnected Graph

  • Recursive DFS procedure visits all vertices
  • f 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)

slide-6
SLIDE 6

CS 16: Connectivity cec

467

Representing Connected Components

Array comp [1..N] comp[k] = i if vertex k is in i-th connectedcomponent

1 2 8 4 6 3 5 7 1 2 3 vertex k 1 2 3 4 5 6 7 8 comp[k] 1 1 2 3 2 3 2 1

slide-7
SLIDE 7

CS 16: Connectivity cec

468

New DFS Algorithm

Inside DFS: replace id = id + 1; val [k] = id; with comp[k] = id; 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);

slide-8
SLIDE 8

CS 16: Connectivity cec

469

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)

slide-9
SLIDE 9

CS 16: Connectivity cec

470

MIA SEA SFO ATL PVD LGA STL LAX LAX DFW ORD MSN DEN

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!

  • Cutvertex: ORD
slide-10
SLIDE 10

CS 16: Connectivity cec

471

Biconnectivity

Biconnected graph: has no cutvertices New flights: LGA-ATL and DFW-LAX make the graph biconnected.

MIA SEA SFO ATL PVD LGA STL LAX LAX DFW ORD MSN DEN

slide-11
SLIDE 11

CS 16: Connectivity cec

472

MIA SEA SFO ATL PVD LGA STL LAX LAX DFW MSN DEN

Properties of Biconnected Graphs

  • 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.

ORD

slide-12
SLIDE 12

CS 16: Connectivity cec

473

MIA SEA SFO ATL PVD LGA STL LAX LAX DFW ORD MSN DEN

Biconnected Components

Biconnected component (block): maximal biconnected subgraph Biconnected components are edge-disjoint but share cutvertices.

slide-13
SLIDE 13

CS 16: Connectivity cec

474

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 (N2 + NM)
slide-14
SLIDE 14

CS 16: Connectivity cec

475

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]

F C B 2 6 7 A 1 D 4 G 5 E 3

We shall characterize cutvertices using the DFS numbering and two properties ...

slide-15
SLIDE 15

CS 16: Connectivity cec

476

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

slide-16
SLIDE 16

CS 16: Connectivity cec

477

root

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. v w root

slide-17
SLIDE 17

CS 16: Connectivity cec

478

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

  • ne back edge
  • Min(v) = val(low(v))

v low(v) Min(v) ________________ A A 1 B A 1 C B 2 D B 2 E B 2 F A 1 1 6 5 D E 4 C 3 F B 2 A

slide-18
SLIDE 18

CS 16: Connectivity cec

479

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!!!!

slide-19
SLIDE 19

CS 16: Connectivity cec

480

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

slide-20
SLIDE 20

CS 16: Connectivity cec

481

MIA SEA SFO ATL PVD LGA STL LAX LAX DFW MSN DEN LAX SAN SJU STT ORD