Graphs-Part-II-Dorr-after-class

Graphs-Part-II-Dorr-after-class - Given a graph one way to...

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

View Full Document Right Arrow Icon
Given a graph, one way to visit every vertex in that graph is via a breadth- first search. Select a starting point. Visit all vertices that are “one jump” away from it. Visit all vertices that are “two jumps” away from it.
Background image of page 1

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

View Full DocumentRight Arrow Icon
A simple problem that can be solved using this general technique is that of finding the shortest path between two vertices in an undirected and unweighted graph. If the graph is not connected, what happens?
Background image of page 2
Starting at vertex s V generate an array of distances from s called dist[] such that for all v V , dist[v]=length of shortest path from s to v. dist[s]=0 We will also create a predecessor array of the last vertex we were at before getting to the end of the path from s to v for all v V , pred[v]=“one step back” pred[s]=none With just these two arrays, we will be able to reconstruct any shortest part request from s to some vertex. This is because any
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.

Page1 / 12

Graphs-Part-II-Dorr-after-class - Given a graph one way to...

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

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