# Lecture 13

Télécharger la présentation

## Lecture 13

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Lecture 13 CSE 331 Oct 2, 2009

2. Announcements Please turn in your HW 3 Graded HW2, solutions to HW 3, HW 4 at the END of the class Maybe extra lectures next week on proofs– check the blog!

3. Connected Component Connected component (of s) is the set of all nodes connected to s

4. Computing Connected Component Start with R = {s} While exists (u,v) edge v not in R and u in R Add v to R Output R

5. R is the connected component of s Claim 1: All vertices in R are connected to s Start with R = {s} Base Case Induction on number of iterations While exists (u,v) edge v not in R and u in R Add v to R I.H.: u is connected to s Output R

6. Today’s agenda If w is not in R then w is not connected to s Depth First Search Computing all connected components Run-time analysis of DFS and BFS

7. A DFS run Every non-tree edge is between a node and its ancestor 1 1 7 2 2 3 8 4 4 5 5 DFS tree 6 6 3 8 7

8. Connected components are disjoint Either Connected components of s and t are the same or are disjoint Algorithm to compute ALL the connected components? Run BFS on some node s. Then run BFS on t that is not connected to s