The University of Texas at Austin
Breadthfirst search
Department of Computer Sciences
Professor Vijaya Ramachandran
Lecture 22
CS357: ALGORITHMS, Spring 2006
1
Breadthfirst search and unweighted shortest paths
We consider here the
singlesource shortest paths
problem on an
unweighted
graph
G
= (
V, E
) (directed or undirected).
Here, we are given as input a
source vertex
s
∈
V
, and we need to find a path of shortest length from
s
to every other vertex
in
V
.
By definition, if there is no path from
s
to a vertex
u
, then the length of a
shortest path from
s
to
u
is
∞
. The wellknown algorithm to solve this problem is
called
breadthfirst search
.
The length of a shortest path from
s
to
u
is called the
distance
from
s
to
u
, and is denoted by
δ
(
s, u
).
We now study the breadthfirst search algorithm that computes shortestpath
dis
tances
from source
s
.
With a small modification, the algorithm also computes a
shortest path tree
rooted
at
s
that gives the edges on a shortest path to each vertex; this is in the textbook,
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '06
 Ramachandran
 Algorithms, Graph Theory, Vertex, Shortest path problem

Click to edit the document details