Depth First Search Neil Tang 4/1/2010

Slides:



Advertisements
Similar presentations
Topological Sort Topological sort is the list of vertices in the reverse order of their finishing times (post-order) of the depth-first search. Topological.
Advertisements

CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Graphs CS-240/341. Graphs Used for representing many-to-many relationships –can take two forms directed (digraph) - a finite set of elements called vertices.
Graph Traversals Reading Material: Chapter 9. Graph Traversals Some applications require visiting every vertex in the graph exactly once. The application.
1 Topological Sort: DFS E C GFB AD A: BDFG B: C: D: E: E F: DE A E H H G: H:
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
1 Topological Sort: DFS F C G A B D E H. 2 F C G A B D E H dfs(A)
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.
Strongly Connected Components for Directed Graphs Kelley Louie Credits: graphs by /demo/graphwin/graphwin.
Hw. 6: Algorithm for finding strongly connected components. Original digraph as drawn in our book and in class: Preorder label : Postorder label Nodes:
1 3/21/2016 MATH 224 – Discrete Mathematics First we determine if a graph is connected.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Representing Graphs Depth First Search Breadth First Search Graph Searching Algorithms.
CSC 172 DATA STRUCTURES.
BCA-II Data Structure Using C Submitted By: Veenu Saini
Data Structures & Algorithm Analysis lec(8):Graph T. Souad alonazi
GRAPH TRAVERSING BY PROF. UZAIR SALMAN
Breadth-First Search (BFS)
CSE 373 Data Structures and Algorithms
Chapter 22 Elementary Graph Algorithms
Tracing An Algorithm for Strongly Connected Components that uses Depth First Search Graph obtained from Text, page a-al: Geetika Tewari.
Thinking about Algorithms Abstractly
Data Structures Graphs - Terminology
Graphs-Part II Depth First Search (DFS)
Graphs Representation, BFS, DFS
Undirected versus Directed Graphs
Data Structures and Algorithms I
Csc 2720 Instructor: Zhuojun Duan
Graph Searching.
CS223 Advanced Data Structures and Algorithms
Unweighted Shortest Path Neil Tang 3/11/2010
CS120 Graphs.
Spanning Trees Longin Jan Latecki Temple University based on slides by
CSE 421: Introduction to Algorithms
Graphs Graph transversals.
Graphs Chapter 13.
Topological Sort Neil Tang 03/02/2010
CS223 Advanced Data Structures and Algorithms
What is a Graph? a b c d e V= {a,b,c,d,e} E= {(a,b),(a,c),(a,d),
Depth-First Search D B A C E Depth-First Search Depth-First Search
Undirected Depth First Search
CSE 373 Data Structures Lecture 16
Spanning Trees Longin Jan Latecki Temple University based on slides by
Subgraphs, Connected Components, Spanning Trees
Depth-First Search D B A C E Depth-First Search Depth-First Search
Algorithms Lecture # 30 Dr. Sohail Aslam.
Discrete Mathematics and
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Algorithms Lecture # 29 Dr. Sohail Aslam.
Depth First Search Neil Tang 4/10/2008
Depth-First Search CSE 2011 Winter April 2019.
Algorithms: Design and Analysis
Breadth-First Search L0 L1 L2 C B A E D F Breadth-First Search
Lecture 6 Graph Traversal
EMIS 8374 Search Algorithms Updated 9 February 2004
Depth-First Search CSE 2011 Winter April 2019.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
A vertex u is reachable from vertex v iff there is a path from v to u.
Chapter 16 1 – Graphs Graph Categories Strong Components
Data structure for graph algorithms: Adjacent list, Adjacent matrix
3.2 Graph Traversal.
Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008
Elementary Graph Algorithms
Podcast Ch24b Title: Strongly Connected Components
Algorithms CSCI 235, Spring 2019 Lecture 33 Graphs II
CS203 Lecture 14.
EMIS 8374 Search Algorithms Updated 12 February 2008
Review for Final Neil Tang 05/01/2008
Presentation transcript:

Depth First Search Neil Tang 4/1/2010 CS223 Advanced Data Structures and Algorithms

CS223 Advanced Data Structures and Algorithms 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

CS223 Advanced Data Structures and Algorithms 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

CS223 Advanced Data Structures and Algorithms DFS A generalized pre-order traversal Time Complexity: O(|V|+|E|) CS223 Advanced Data Structures and Algorithms

DFS on An Undirected Graph DFS(A): A,B,C,D,E CS223 Advanced Data Structures and Algorithms

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

CS223 Advanced Data Structures and Algorithms 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 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 Components Gr 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) The forest after the first DFS CS223 Advanced Data Structures and Algorithms