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

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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 ] 0 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? Answer: Once. So | V | for add operation How many times is adjaceny list of vertex v scanned?
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern