lec27-28 - CS C341 IS C361 Data Structures& Algorithms...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 16

lec27-28 - CS C341 IS C361 Data Structures& Algorithms...

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

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