18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lecture 16 - applications of DFS and BFS<br />

<strong>The</strong>re is an amazingly elegant, linear time algorithm to find the strongly connected components of a<br />

directed graph, using DFS.<br />

Listen To Part 17-13<br />

● Call DFS( ) to compute finishing times for each vertex.<br />

● Compute the transpose graph (reverse all edges in G)<br />

● Call DFS( ), but order the vertices in decreasing order of finish time.<br />

● <strong>The</strong> vertices of each DFS tree in the forest of DFS( ) is a strongly connected component.<br />

This algorithm takes O(n+m), but why does it compute strongly connected components?<br />

Lemma: If two vertices are in the same strong component, no path between them ever leaves the<br />

component.<br />

Lemma: In any DFS forest, all vertices in the same strongly connected component are in the same tree.<br />

Proof: Consider the first vertex v in the component to be discovered. Everything in the component is<br />

reachable from it, so we will traverse it before finishing with v.<br />

Listen To Part 17-14<br />

What does DFS( , v) Do?<br />

It tells you what vertices have directed paths to v, while DFS( ,v) tells what vertices have directed paths<br />

from v. But why must any vertex in the search tree of DFS( , v) also have a path from u?<br />

file:///E|/LEC/LECTUR16/NODE16.HTM (3 of 5) [19/1/2003 1:35:10]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!