This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS C341 / IS C361 Data Structures & Algorithms GRAPH ALGORITHMS Directed Graphs Reachability and Strong connectivity Traversal Transitive Closure Application – Garbage Collection Directed Acyclic Graphs Topological Sorting 1 02/07/11 Sundar B. CSIS, BITS, Pilani DIRECTED GRAPHS Directed graphs are also referred to as digraphs Reachability Directed path v is reachable from u, if there is a directed path from u to v Also referred to as: u reaches v A digraph G> is strongly connected if for any two vertices u and v of G> , u reaches v and v reaches u. A directed cycle is a directed path from u to u. A digraph G> is acyclic if it has no directed cycles. The transitive closure of a digraph G> is the digraph G>* such that the vertices of G>* are the same as the vertices of G> , and G>* has an edge (u,v) whenever G> has a directed path 02/07/11 2 Sundar B. CSIS, BITS, Pilani TRAVERSING A DIGRAPH A directed DFS partitions the edges reachable from the starting vertex into Discovery edges (or tree edges) and Nontree edges 3 types of nontree edges Back edges: vertex to an ancestor in the directed DFS tree Forward edges: vertex to a descendant in the DFS tree Cross edges: vertex to another that is neither a descendant nor an ancestor 02/07/11 3 Sundar B. CSIS, BITS, Pilani DFS: EXAMPLE 02/07/11 4 Sundar B. CSIS, BITS, Pilani 1 3 2 6 4 5 • DFS Steps: • 1,2,3, 9 7 8 10 A E F G D B C • backtrack to C • 4,5 • backtrack to B • 6 < forward edge • backtrack to A • 7 • 8 < cross edge • backtrack to F • 9 < cross edge • backtrack to F • 10 < back edge DIRECTED GRAPHS – STRONG CONNECTIVITY Testing strong connectivity: (Given digraph G> ) Pick an arbitrary vertex r DFS(r) If any vertex of G> is not visited then G> is not strongly connected....
View
Full
Document
This note was uploaded on 02/07/2011 for the course CS 123 taught by Professor Murali during the Spring '11 term at Birla Institute of Technology & Science, Pilani  Hyderabad.
 Spring '11
 Murali
 Algorithms, Data Structures, Sort

Click to edit the document details