lecture16 - Graph Theory Breadth First Search IE170:...

Info iconThis preview shows pages 1–3. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Graph Theory Breadth First Search IE170: Algorithms in Systems Engineering: Lecture 16 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University February 28, 2007 Jeff Linderoth IE170:Lecture 16 Graph Theory Breadth First Search Taking Stock Last Time The Wonderful World of Graph Theory Breadth First Search This Time Finish Breadth-First Search Depth-First Search Jeff Linderoth IE170:Lecture 16 Graph Theory Breadth First Search Graph Search Algorithms There are two “workhorse” algorithms for searching graphs that form the basis for many more complicated algorithms. Breadth-First Search (BFS): Search “broadly” Depth-First Search (DFS): Search “deeply” BFS: Last Time DFS: Today Jeff Linderoth IE170:Lecture 16 Graph Theory Breadth First Search Recall—BFS BFS Input : Graph G = ( V, E ) , source node s ∈ V Output : d ( v ) , distance (smallest # of edges) from s to v ∀ v ∈ V Output : π ( v ) , predecessor of v on the shortest path from s to v Oh no! DP again δ ( s, v ) : shortest path from s to v Lemma: If ( u, v ) ∈ E , then δ ( s, v ) ≤ δ ( s, u ) + 1 Jeff Linderoth IE170:Lecture 16 Graph Theory Breadth First Search BFS BFS ( V, E, s ) 1 for each u in V \ { s } 2 do d ( u ) ← ∞ 3 π ( u ) ← nil 4 d [ s ] ← 5 Q ← ∅ 6 add ( Q, s ) 7 while Q = ∅ 8 do u ← poll ( Q ) 9 for each v in Adj [ u ] 10 do if d [ v ] = ∞ 11 then d [ v ] ← d [ u ] + 1 12 π [ v ] = u 13 add ( Q, v ) Jeff Linderoth IE170:Lecture 16 Graph Theory Breadth First Search Analysis How many times is each vertex added?...
View Full Document

This note was uploaded on 08/06/2008 for the course IE 170 taught by Professor Ralphs during the Spring '07 term at Lehigh University .

Page1 / 6

lecture16 - Graph Theory Breadth First Search IE170:...

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

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