This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Cycles Shortest paths can’t contain cycles:
Already ruled out negative-weight cycles.
Positive-weight: we can get a shorter path by omitting the cycle.
Zero-weight: no reason to use them
won’t use them. CSE 2011
Prof. J. Elder - 176 - assume that our solutions Last Updated: 4/1/10 10:16 AM Shortest-Path Example: Single-Source CSE 2011
Prof. J. Elder - 177 - Last Updated: 4/1/10 10:16 AM Output of a single-source shortest-path algorithm
For each vertex v in V:
d[v] = (s, v).
Initially, d[v]= .
Reduce as algorithm progresses.
But always maintain d[v]
Call d[v] a shortest-path estimate. [v] = predecessor of v on a shortest path from s.
If no predecessor, [v] = NIL.
induces a tree — shortest-path tree.
Prof. J. Elder - 178 - Last Updated: 4/1/10 10:16 AM Initialization
All shortest-paths algorithms start with the
for each v in V
[v] d[s] NIL 0 CSE 2011
Prof. J. Elder - 179 - Last Updated: 4/1/10 10:16 AM Relaxing an edge
Can we improve shortest-path estimate for v by first going to u
and then following edge (u,v)?
RELAX(u, v, w)
if d[v] > d[u] + w(u, v) then
[v] CSE 2011
Prof. J. Elder d[u] + w(u, v)
u - 180 - Last Updated: 4/1/10 10:16 AM ...
View Full Document
This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.
- Fall '11
- Data Structures