CS223-0410-DFS

CS223-0410-DFS - DFS on An Undirected Graph DFS can be used...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS223 Advanced Data Structures and Algorithms 1 Depth First Search Depth First Search Neil Tang Neil Tang 4/10/2008 4/10/2008
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS223 Advanced Data Structures and Algorithms 2 Class Overview Class Overview Breadth First Search (BFS) Depth First Search (DFS) DFS on an undirected graph DFS on a digraph Strong connected components
Background image of page 2
CS223 Advanced Data Structures and Algorithms 3 BFS BFS Visit the nodes that are one-hop away from the starting node one by one, then the nodes that are two-hop away, then … A queue should be used to implement the BFS. Make sure each node is visited exactly once.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS223 Advanced Data Structures and Algorithms 4 DFS DFS A generalized pre-order traversal Time Complexity: O(|V|+|E|)
Background image of page 4
CS223 Advanced Data Structures and Algorithms 5 DFS on An Undirected Graph DFS on An Undirected Graph DFS(A): A,B,C,D,E
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS223 Advanced Data Structures and Algorithms 6 DFS on An Undirected Graph
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: DFS on An Undirected Graph DFS can be used to find if an undirected graph is connected or not. DFS can also be used to find all the connected components. CS223 Advanced Data Structures and Algorithms 7 DFS on A Digraph DFS on A Digraph DFS(B): B,C,A,D,E,F; DFS(H): H,J,I; DFS(G): G. CS223 Advanced Data Structures and Algorithms 8 Strong Connected Components Strong Connected Components Perform DFS until all nodes are visited. Construct an auxiliary graph G r . Perform DFS on G r in the reverse order of the numbers. CS223 Advanced Data Structures and Algorithms 9 Strong Connected Components Strong Connected Components DFS(G): G; DFS(H): H,I,J; DFS(B): B,A,C,F; DFS(D): D; DFS(E): E. Strong Connected Components: (G), (H,I,J), (B,A,C,F),(D),(E) G r The spanning tree after the first DFS...
View Full Document

Page1 / 9

CS223-0410-DFS - DFS on An Undirected Graph DFS can be used...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online