depth first search neil tang 4 1 2010 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Depth First Search Neil Tang 4/1/2010 PowerPoint Presentation
Download Presentation
Depth First Search Neil Tang 4/1/2010

Loading in 2 Seconds...

play fullscreen
1 / 9

Depth First Search Neil Tang 4/1/2010 - PowerPoint PPT Presentation


  • 96 Views
  • Uploaded on

Depth First Search Neil Tang 4/1/2010. Class Overview. Breadth First Search (BFS) Depth First Search (DFS) DFS on an undirected graph DFS on a digraph Strong connected components. BFS.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Depth First Search Neil Tang 4/1/2010' - cwen


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
depth first search neil tang 4 1 2010

Depth First Search Neil Tang4/1/2010

CS223 Advanced Data Structures and Algorithms

class overview
Class Overview
  • Breadth First Search (BFS)
  • Depth First Search (DFS)
  • DFS on an undirected graph
  • DFS on a digraph
  • Strong connected components

CS223 Advanced Data Structures and Algorithms

slide3
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 …, i.e., layer by layer.
  • A queue should be used to implement the BFS.
  • Make sure each node is visited exactly once.

CS223 Advanced Data Structures and Algorithms

slide4
DFS
  • A generalized pre-order traversal

Time Complexity: O(|V|+|E|)

CS223 Advanced Data Structures and Algorithms

dfs on an undirected graph
DFS on An Undirected Graph

DFS(A): A,B,C,D,E

CS223 Advanced Data Structures and Algorithms

dfs on an undirected graph1
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

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

strongly connected components
Strongly Connected Components
  • Perform DFS until all nodes are visited.
  • Construct an auxiliary graph Gr.
  • Perform DFS on Gr in the reverse order of the index numbers.

CS223 Advanced Data Structures and Algorithms

strongly connected components1
Strongly Connected Components

DFS(G): G;

DFS(H): H,I,J;

DFS(B): B,A,C,F;

DFS(D): D; DFS(E): E.

Strongly Connected Components: (G), (H,I,J), (B,A,C,F),(D),(E)

Gr

The forest after the first DFS

CS223 Advanced Data Structures and Algorithms