SlideShare a Scribd company logo
Single-Source Shortest Paths
Mrs.R.Shanthi Prabha M.Sc., M.Phil.,
Assistant Professor,
DEPARTMENT OF Computer Science
Sacwc, cumbum
Outline
 General Lemmas and Theorems.
 CLRS now does this last. We’ll still do it first.
 Bellman-Ford algorithm.
 DAG algorithm.
 Dijkstra’s algorithm.
 We will skip Section 24.4.
General Results (Relaxation)
Corollary: Let p = SP from s to v, where p = s u v. Then,
δ(s, v) = δ(s, u) + w(u, v).
Lemma 24.1: Let p = ‹v1, v2, …, vk› be a SP from v1 to vk. Then,
pij = ‹vi, vi+1, …, vj› is a SP from vi to vj, where 1  i  j  k.
So, we have the optimal-substructure property.
Bellman-Ford’s algorithm uses dynamic programming.
Dijkstra’s algorithm uses the greedy approach.
Let δ(u, v) = weight of SP from u to v.

p'
Lemma 24.10: Let s  V. For all edges (u,v)  E, we have
δ(s, v)  δ(s, u) + w(u,v).
RelaxationInitialize(G, s)
for each v  V[G] do
d[v] := ;
[v] := NIL
od;
d[s] := 0
Relax(u, v, w)
if d[v] > d[u] + w(u, v) then
d[v] := d[u] + w(u, v);
[v] := u
fi
Algorithms keep track of d[v], [v]. Initialized as follows:
These values are changed when an edge (u, v) is relaxed:
Properties of Relaxation
 d[v], if not , is the length of some path from s to v.
 d[v] either stays the same or decreases with time
 Therefore, if d[v] = (s, v) at any time, this holds
thereafter
 Note that d[v]  (s, v) always
 After i iterations of relaxing on all (u,v), if the shortest
path to v has i edges, then d[v] = (s, v).
Comp 122, Fall 2003
Single-
source SPs -
5
Properties of Relaxation
Comp 122, Fall 2003
Single-
source SPs -
6
Consider any algorithm in which d[v], and [v] are first initialized
by calling Initialize(G, s) [s is the source], and are only changed by
calling Relax. We have:
Lemma 24.11: ( v:: d[v]  (s, v)) is an invariant.
Implies d[v] doesn’t change once d[v] = (s, v).
Proof:
Initialize(G, s) establishes invariant. If call to Relax(u, v, w)
changes d[v], then it establishes:
d[v] = d[u] + w(u, v)
 (s, u) + w(u, v) , invariant holds before call.
 (s, v) , by Lemma 24.10.
Corollary 24.12: If there is no path from s to v, then
d[v] = δ(s, v) =  is an invariant.
More Properties
Comp 122, Fall 2003
Single-
source SPs -
7
Lemma 24.14: Let p = SP from s to v, where p = s u v.
If d[u] = δ(s, u) holds at any time prior to calling Relax(u, v, w),
then d[v] = δ(s, v) holds at all times after the call.

p'
Proof:
After the call we have:
d[v]  d[u] + w(u, v) , by Lemma 24.13.
= (s, u) + w(u, v) , d[u] = (s, u) holds.
= (s, v) , by corollary to Lemma 24.1.
By Lemma 24.11, d[v]  δ(s, v), so d[v] = δ(s, v).
Lemma 24.13: Immediately after relaxing edge (u, v) by calling
Relax(u, v, w), we have d[v]  d[u] + w(u, v).
 Bellman-Ford returns a compact representation of the
set of shortest paths from s to all other vertices in the
graph reachable from s. This is contained in the
predecessor subgraph.
Comp 122, Fall 2003
Single-
source SPs -
8
Predecessor Subgraph
Comp 122, Fall 2003
Single-
source SPs -
9
Lemma 24.16: Assume given graph G has no negative-weight cycles
reachable from s. Let G = predecessor subgraph. G is always a
tree with root s (i.e., this property is an invariant).
Proof:
Two proof obligations:
(1) G is acyclic.
(2) There exists a unique path from source s to each vertex in V.
Proof of (1):
Suppose there exists a cycle c = ‹v0, v1, …, vk›, where v0 = vk.
We have [vi] = vi-1 for i = 1, 2, …, k.
Assume relaxation of (vk-1, vk) created the cycle.
We show cycle has a negative weight.
Note: Cycle must be reachable from s. (Why?)
Proof of (1) (Continued)
Comp 122, Fall 2003
Single-
source SPs -
10
Before call to Relax(vk-1, vk, w):
[vi] = vi-1 for i = 1, …, k–1.
Implies d[vi] was last updated by “d[vi] := d[vi-1] + w(vi-1, vi)”
for i = 1, …, k–1. [Because Relax updates .]
Implies d[vi]  d[vi-1] + w(vi-1, vi) for i = 1, …, k–1. [Lemma 24.13]
Because [vk] is changed by call, d[vk] > d[vk-1] + w(vk-1, vk). Thus,
cycle!
weight
-
neg.
i.e.,
0,
)
v
,
w(v
,
]
d[v
]
d[v
Because
)
v
,
w(v
]
d[v
))
v
,
w(v
]
(d[v
]
d[v
k
1
i
i
1
i
k
1
i
1
i
k
1
i
i
k
1
i
k
1
i
i
1
i
1
i
k
1
i
k
1
i
i
1
i
1
i
i









 
 





 


 


Comment on Proof
 d[vi]  d[vi-1] + w(vi-1,vi) for i = 1, …, k–1 because when
Relax(vi-1 ,vi , w) was called, there was an equality, and
d[vi-1] may have gotten smaller by further calls to Relax.
 d[vk] > d[vk-1] + w(vk-1,vk) before the last call to Relax
because that last call changed d[vk].
Comp 122, Fall 2003
Single-
source SPs -
11
Proof of (2)
Comp 122, Fall 2003
Single-
source SPs -
12
Proof of (2):
( v: v  V:: ( path from s to v)) is an invariant.
So, for any v in V,  at least 1 path from s to v.
Show  1 path.
Assume 2 paths.
s u
y
x
z v
impossible!
Lemma 24.17
Comp 122, Fall 2003
Single-
source SPs -
13
Lemma 24.17: Same conditions as before. Call Initialize & repeatedly
call Relax until d[v] = δ(s, v) for all v in V. Then, G is a shortest-path
tree rooted at s.
Proof:
Key Proof Obligation: For all v in V, the unique simple path p from
s to v in G (path exists by Lemma 24.16) is a shortest path from s to v
in G.
Let p = ‹v0, v1, …, vk›, where v0 = s and vk = v.
We have d[vi] = δ(s, vi)
d[vi]  d[vi-1] + w(vi-1, vi) (reasoning as before)
Implies w(vi-1, vi)  δ(s, vi) – δ(s, vi-1).
Proof (Continued)
Comp 122, Fall 2003
Single-
source SPs -
14
)
v
,
δ(s
)
v
,
δ(s
)
v
,
δ(s
))
v
,
δ(s
)
v
,
δ(s
(
)
v
,
w(v
w(p)
k
0
k
1
-
i
i
k
1
i
k
1
i
i
1
i











So, equality holds and p is a shortest path.
Bellman-Ford Algorithm
Comp 122, Fall 2003
Single-
source SPs -
15
Can have negative-weight edges. Will “detect” reachable negative-weight
cycles.
Initialize(G, s);
for i := 1 to |V[G]| –1 do
for each (u, v) in E[G] do
Relax(u, v, w)
od
od;
for each (u, v) in E[G] do
if d[v] > d[u] + w(u, v) then
return false
fi
od;
return true
Time
Complexity
is O(VE).
 So if Bellman-Ford has not converged after V(G) - 1
iterations, then there cannot be a shortest path tree, so
there must be a negative weight cycle.
Comp 122, Fall 2003
Single-
source SPs -
16
Example
Comp 122, Fall 2003
Single-
source SPs -
17
0




z
u v
x y
6
5
–3
9
7
7
8
–2
–4
2
Example
Comp 122, Fall 2003
Single-
source SPs -
18
0

7

6
z
u v
x y
6
5
–3
9
7
7
8
–2
–4
2
Example
Comp 122, Fall 2003
Single-
source SPs -
19
0
2
7
4
6
z
u v
x y
6
5
–3
9
7
7
8
–2
–4
2
Example
Comp 122, Fall 2003
Single-
source SPs -
20
0
2
7
4
2
z
u v
x y
6
5
–3
9
7
7
8
–2
–4
2
Example
Comp 122, Fall 2003
Single-
source SPs -
21
0
-2
7
4
2
z
u v
x y
6
5
–3
9
7
7
8
–2
–4
2
Another Look
Comp 122, Fall 2003
Single-
source SPs -
22
Note: This is essentially dynamic programming.
Let d(i, j) = cost of the shortest path from s to i that is at most j hops.
d(i, j) =
0 if i = s  j = 0
 if i  s  j = 0
min({d(k, j–1) + w(k, i): i  Adj(k)}
 {d(i, j–1)}) if j > 0
z u v x y
1 2 3 4 5
0 0    
1 0 6  7 
2 0 6 4 7 2
3 0 2 4 7 2
4 0 2 4 7 –2
j
i
Lemma 24.2
Comp 122, Fall 2003
Single-
source SPs -
23
Lemma 24.2: Assuming no negative-weight cycles reachable from
s, d[v] = (s, v) holds upon termination for all vertices v reachable
from s.
Proof:
Consider a SP p, where p = ‹v0, v1, …, vk›, where v0 = s and vk = v.
Assume k  |V| – 1, otherwise p has a cycle.
Claim: d[vi] = (s, vi) holds after the ith pass over edges.
Proof follows by induction on i.
By Lemma 24.11, once d[vi] = (s, vi) holds, it continues to hold.
Correctness
Comp 122, Fall 2003
Single-
source SPs -
24
Claim: Algorithm returns the correct value.
(Part of Theorem 24.4. Other parts of the theorem follow easily from earlier results.)
Case 1: There is no reachable negative-weight cycle.
Upon termination, we have for all (u, v):
d[v] = (s, v) , by lemma 24.2 (last slide) if v is reachable;
d[v] = (s, v) =  otherwise.
 (s, u) + w(u, v) , by Lemma 24.10.
= d[u] + w(u, v)
So, algorithm returns true.
Case 2
Comp 122, Fall 2003
Single-
source SPs -
25
Case 2: There exists a reachable negative-weight cycle
c = ‹v0, v1, …, vk›, where v0 = vk.
We have i = 1, …, k w(vi-1, vi) < 0. (*)
Suppose algorithm returns true. Then, d[vi]  d[vi-1] + w(vi-1, vi) for
i = 1, …, k. (because Relax didn’t change any d[vi] ). Thus,
i = 1, …, k d[vi]  i = 1, …, k d[vi-1] + i = 1, …, k w(vi-1, vi)
But, i = 1, …, k d[vi] = i = 1, …, k d[vi-1].
Can show no d[vi] is infinite. Hence, 0  i = 1, …, k w(vi-1, vi).
Contradicts (*). Thus, algorithm returns false.
Shortest Paths in DAGs
Comp 122, Fall 2003
Single-
source SPs -
26
Topologically sort vertices in G;
Initialize(G, s);
for each u in V[G] (in order) do
for each v in Adj[u] do
Relax(u, v, w)
od
od
Example
Comp 122, Fall 2003
Single-
source SPs -
27
 0    
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
28
 0    
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
29
 0 2 6  
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
30
 0 2 6 6 4
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
31
 0 2 6 5 4
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
32
 0 2 6 5 3
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Example
Comp 122, Fall 2003
Single-
source SPs -
33
 0 2 6 5 3
r s t u v w
5 2 7 –1 –2
6 1
3
2
4
Dijkstra’s Algorithm
Comp 122, Fall 2003
Single-
source SPs -
34
Assumes no negative-weight edges.
Maintains a set S of vertices whose SP from s has been determined.
Repeatedly selects u in V–S with minimum SP estimate (greedy choice).
Store V–S in priority queue Q.
Initialize(G, s);
S := ;
Q := V[G];
while Q   do
u := Extract-Min(Q);
S := S  {u};
for each v  Adj[u] do
Relax(u, v, w)
od
od
Example
Comp 122, Fall 2003
Single-
source SPs -
35
0




s
u v
x y
10
1
9
2
4 6
5
2 3
7
Example
Comp 122, Fall 2003
Single-
source SPs -
36
0

5

10
s
u v
x y
10
1
9
2
4 6
5
2 3
7
Example
Comp 122, Fall 2003
Single-
source SPs -
37
0
7
5
14
8
s
u v
x y
10
1
9
2
4 6
5
2 3
7
Example
Comp 122, Fall 2003
Single-
source SPs -
38
0
7
5
13
8
s
u v
x y
10
1
9
2
4 6
5
2 3
7
Example
Comp 122, Fall 2003
Single-
source SPs -
39
0
7
5
9
8
s
u v
x y
10
1
9
2
4 6
5
2 3
7
Example
Comp 122, Fall 2003
Single-
source SPs -
40
0
7
5
9
8
s
u v
x y
10
1
9
2
4 6
5
2 3
7

More Related Content

What's hot

Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
Nv Thejaswini
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
Krish_ver2
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
vishal choudhary
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Amit Kumar Rathi
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 
Linked List
Linked ListLinked List
Linked List
Ashim Lamichhane
 
Recursion
RecursionRecursion
Recursion
Abdur Rehman
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
sandeep54552
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
Md. Shafiuzzaman Hira
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
Basit Ali
 
Strassen.ppt
Strassen.pptStrassen.ppt
Strassen.ppt
ShivareddyGangam
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
Syed Ahmed
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
jyoti_lakhani
 
Heaps
HeapsHeaps
Digital Logic & Design
Digital Logic & DesignDigital Logic & Design
Digital Logic & Design
Rokonuzzaman Rony
 

What's hot (20)

Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Linked List
Linked ListLinked List
Linked List
 
Recursion
RecursionRecursion
Recursion
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
 
Bit pair recoding
Bit pair recodingBit pair recoding
Bit pair recoding
 
Strassen.ppt
Strassen.pptStrassen.ppt
Strassen.ppt
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
 
Heaps
HeapsHeaps
Heaps
 
Digital Logic & Design
Digital Logic & DesignDigital Logic & Design
Digital Logic & Design
 

Similar to SINGLE SOURCE SHORTEST PATH.ppt

Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
Amit Kumar Rathi
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
B.Kirron Reddi
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
SaimaShaheen14
 
Bellman ford
Bellman fordBellman ford
Bellman ford
Kiran K
 
20 Single Source Shorthest Path
20 Single Source Shorthest Path20 Single Source Shorthest Path
20 Single Source Shorthest Path
Andres Mendez-Vazquez
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
Kazi Emad
 
Graphs: Finding shortest paths
Graphs: Finding shortest pathsGraphs: Finding shortest paths
Graphs: Finding shortest paths
Fulvio Corno
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
Dr Sandeep Kumar Poonia
 
Shortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairsShortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairs
Benjamin Sach
 
Chapter 25 aoa
Chapter 25 aoaChapter 25 aoa
Chapter 25 aoa
Hanif Durad
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
Ruchika Sinha
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
lecture 21
lecture 21lecture 21
lecture 21
sajinsc
 
Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14
Naor Ami
 
Floyd warshall algo {dynamic approach}
Floyd warshall algo {dynamic approach}Floyd warshall algo {dynamic approach}
Floyd warshall algo {dynamic approach}
Shubham Shukla
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
taimurkhan803
 
Dijksatra
DijksatraDijksatra
Dijksatra
Tanmay Baranwal
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
Krish_ver2
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
A. S. M. Shafi
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdf
NanaKoori
 

Similar to SINGLE SOURCE SHORTEST PATH.ppt (20)

Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
 
Bellman ford
Bellman fordBellman ford
Bellman ford
 
20 Single Source Shorthest Path
20 Single Source Shorthest Path20 Single Source Shorthest Path
20 Single Source Shorthest Path
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
 
Graphs: Finding shortest paths
Graphs: Finding shortest pathsGraphs: Finding shortest paths
Graphs: Finding shortest paths
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Shortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairsShortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairs
 
Chapter 25 aoa
Chapter 25 aoaChapter 25 aoa
Chapter 25 aoa
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
 
lecture 21
lecture 21lecture 21
lecture 21
 
Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14
 
Floyd warshall algo {dynamic approach}
Floyd warshall algo {dynamic approach}Floyd warshall algo {dynamic approach}
Floyd warshall algo {dynamic approach}
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Dijksatra
DijksatraDijksatra
Dijksatra
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdf
 

More from shanthishyam

C&NS_FIREWALLS.ppt
C&NS_FIREWALLS.pptC&NS_FIREWALLS.ppt
C&NS_FIREWALLS.ppt
shanthishyam
 
Cryptography and Network Security_Chapter 1.ppt
Cryptography and Network Security_Chapter 1.pptCryptography and Network Security_Chapter 1.ppt
Cryptography and Network Security_Chapter 1.ppt
shanthishyam
 
TOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.pptTOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.ppt
shanthishyam
 
FDS- Basic Concepts.ppt
FDS- Basic Concepts.pptFDS- Basic Concepts.ppt
FDS- Basic Concepts.ppt
shanthishyam
 
Three dimensional geometric transformations
Three dimensional geometric transformationsThree dimensional geometric transformations
Three dimensional geometric transformations
shanthishyam
 
OSI reference model
OSI reference modelOSI reference model
OSI reference model
shanthishyam
 
Database concepts
Database conceptsDatabase concepts
Database concepts
shanthishyam
 
Curve modeling
Curve modelingCurve modeling
Curve modeling
shanthishyam
 
Cryptography and network security
Cryptography and network securityCryptography and network security
Cryptography and network security
shanthishyam
 
Computer networks
Computer networksComputer networks
Computer networks
shanthishyam
 

More from shanthishyam (10)

C&NS_FIREWALLS.ppt
C&NS_FIREWALLS.pptC&NS_FIREWALLS.ppt
C&NS_FIREWALLS.ppt
 
Cryptography and Network Security_Chapter 1.ppt
Cryptography and Network Security_Chapter 1.pptCryptography and Network Security_Chapter 1.ppt
Cryptography and Network Security_Chapter 1.ppt
 
TOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.pptTOKEN BUS & TOKEN RING.ppt
TOKEN BUS & TOKEN RING.ppt
 
FDS- Basic Concepts.ppt
FDS- Basic Concepts.pptFDS- Basic Concepts.ppt
FDS- Basic Concepts.ppt
 
Three dimensional geometric transformations
Three dimensional geometric transformationsThree dimensional geometric transformations
Three dimensional geometric transformations
 
OSI reference model
OSI reference modelOSI reference model
OSI reference model
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
Curve modeling
Curve modelingCurve modeling
Curve modeling
 
Cryptography and network security
Cryptography and network securityCryptography and network security
Cryptography and network security
 
Computer networks
Computer networksComputer networks
Computer networks
 

Recently uploaded

Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
IshaGoswami9
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
HongcNguyn6
 
THEMATIC APPERCEPTION TEST(TAT) cognitive abilities, creativity, and critic...
THEMATIC  APPERCEPTION  TEST(TAT) cognitive abilities, creativity, and critic...THEMATIC  APPERCEPTION  TEST(TAT) cognitive abilities, creativity, and critic...
THEMATIC APPERCEPTION TEST(TAT) cognitive abilities, creativity, and critic...
Abdul Wali Khan University Mardan,kP,Pakistan
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
European Sustainable Phosphorus Platform
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
vluwdy49
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
RitabrataSarkar3
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
İsa Badur
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
Daniel Tubbenhauer
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
MaheshaNanjegowda
 
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Leonel Morgado
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
Texas Alliance of Groundwater Districts
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
Sérgio Sacani
 
Randomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNERandomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNE
University of Maribor
 
Cytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptxCytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptx
Hitesh Sikarwar
 
Shallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptxShallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptx
Gokturk Mehmet Dilci
 

Recently uploaded (20)

Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
 
THEMATIC APPERCEPTION TEST(TAT) cognitive abilities, creativity, and critic...
THEMATIC  APPERCEPTION  TEST(TAT) cognitive abilities, creativity, and critic...THEMATIC  APPERCEPTION  TEST(TAT) cognitive abilities, creativity, and critic...
THEMATIC APPERCEPTION TEST(TAT) cognitive abilities, creativity, and critic...
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
 
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
 
Randomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNERandomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNE
 
Cytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptxCytokines and their role in immune regulation.pptx
Cytokines and their role in immune regulation.pptx
 
Shallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptxShallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptx
 

SINGLE SOURCE SHORTEST PATH.ppt

  • 1. Single-Source Shortest Paths Mrs.R.Shanthi Prabha M.Sc., M.Phil., Assistant Professor, DEPARTMENT OF Computer Science Sacwc, cumbum
  • 2. Outline  General Lemmas and Theorems.  CLRS now does this last. We’ll still do it first.  Bellman-Ford algorithm.  DAG algorithm.  Dijkstra’s algorithm.  We will skip Section 24.4.
  • 3. General Results (Relaxation) Corollary: Let p = SP from s to v, where p = s u v. Then, δ(s, v) = δ(s, u) + w(u, v). Lemma 24.1: Let p = ‹v1, v2, …, vk› be a SP from v1 to vk. Then, pij = ‹vi, vi+1, …, vj› is a SP from vi to vj, where 1  i  j  k. So, we have the optimal-substructure property. Bellman-Ford’s algorithm uses dynamic programming. Dijkstra’s algorithm uses the greedy approach. Let δ(u, v) = weight of SP from u to v.  p' Lemma 24.10: Let s  V. For all edges (u,v)  E, we have δ(s, v)  δ(s, u) + w(u,v).
  • 4. RelaxationInitialize(G, s) for each v  V[G] do d[v] := ; [v] := NIL od; d[s] := 0 Relax(u, v, w) if d[v] > d[u] + w(u, v) then d[v] := d[u] + w(u, v); [v] := u fi Algorithms keep track of d[v], [v]. Initialized as follows: These values are changed when an edge (u, v) is relaxed:
  • 5. Properties of Relaxation  d[v], if not , is the length of some path from s to v.  d[v] either stays the same or decreases with time  Therefore, if d[v] = (s, v) at any time, this holds thereafter  Note that d[v]  (s, v) always  After i iterations of relaxing on all (u,v), if the shortest path to v has i edges, then d[v] = (s, v). Comp 122, Fall 2003 Single- source SPs - 5
  • 6. Properties of Relaxation Comp 122, Fall 2003 Single- source SPs - 6 Consider any algorithm in which d[v], and [v] are first initialized by calling Initialize(G, s) [s is the source], and are only changed by calling Relax. We have: Lemma 24.11: ( v:: d[v]  (s, v)) is an invariant. Implies d[v] doesn’t change once d[v] = (s, v). Proof: Initialize(G, s) establishes invariant. If call to Relax(u, v, w) changes d[v], then it establishes: d[v] = d[u] + w(u, v)  (s, u) + w(u, v) , invariant holds before call.  (s, v) , by Lemma 24.10. Corollary 24.12: If there is no path from s to v, then d[v] = δ(s, v) =  is an invariant.
  • 7. More Properties Comp 122, Fall 2003 Single- source SPs - 7 Lemma 24.14: Let p = SP from s to v, where p = s u v. If d[u] = δ(s, u) holds at any time prior to calling Relax(u, v, w), then d[v] = δ(s, v) holds at all times after the call.  p' Proof: After the call we have: d[v]  d[u] + w(u, v) , by Lemma 24.13. = (s, u) + w(u, v) , d[u] = (s, u) holds. = (s, v) , by corollary to Lemma 24.1. By Lemma 24.11, d[v]  δ(s, v), so d[v] = δ(s, v). Lemma 24.13: Immediately after relaxing edge (u, v) by calling Relax(u, v, w), we have d[v]  d[u] + w(u, v).
  • 8.  Bellman-Ford returns a compact representation of the set of shortest paths from s to all other vertices in the graph reachable from s. This is contained in the predecessor subgraph. Comp 122, Fall 2003 Single- source SPs - 8
  • 9. Predecessor Subgraph Comp 122, Fall 2003 Single- source SPs - 9 Lemma 24.16: Assume given graph G has no negative-weight cycles reachable from s. Let G = predecessor subgraph. G is always a tree with root s (i.e., this property is an invariant). Proof: Two proof obligations: (1) G is acyclic. (2) There exists a unique path from source s to each vertex in V. Proof of (1): Suppose there exists a cycle c = ‹v0, v1, …, vk›, where v0 = vk. We have [vi] = vi-1 for i = 1, 2, …, k. Assume relaxation of (vk-1, vk) created the cycle. We show cycle has a negative weight. Note: Cycle must be reachable from s. (Why?)
  • 10. Proof of (1) (Continued) Comp 122, Fall 2003 Single- source SPs - 10 Before call to Relax(vk-1, vk, w): [vi] = vi-1 for i = 1, …, k–1. Implies d[vi] was last updated by “d[vi] := d[vi-1] + w(vi-1, vi)” for i = 1, …, k–1. [Because Relax updates .] Implies d[vi]  d[vi-1] + w(vi-1, vi) for i = 1, …, k–1. [Lemma 24.13] Because [vk] is changed by call, d[vk] > d[vk-1] + w(vk-1, vk). Thus, cycle! weight - neg. i.e., 0, ) v , w(v , ] d[v ] d[v Because ) v , w(v ] d[v )) v , w(v ] (d[v ] d[v k 1 i i 1 i k 1 i 1 i k 1 i i k 1 i k 1 i i 1 i 1 i k 1 i k 1 i i 1 i 1 i i                          
  • 11. Comment on Proof  d[vi]  d[vi-1] + w(vi-1,vi) for i = 1, …, k–1 because when Relax(vi-1 ,vi , w) was called, there was an equality, and d[vi-1] may have gotten smaller by further calls to Relax.  d[vk] > d[vk-1] + w(vk-1,vk) before the last call to Relax because that last call changed d[vk]. Comp 122, Fall 2003 Single- source SPs - 11
  • 12. Proof of (2) Comp 122, Fall 2003 Single- source SPs - 12 Proof of (2): ( v: v  V:: ( path from s to v)) is an invariant. So, for any v in V,  at least 1 path from s to v. Show  1 path. Assume 2 paths. s u y x z v impossible!
  • 13. Lemma 24.17 Comp 122, Fall 2003 Single- source SPs - 13 Lemma 24.17: Same conditions as before. Call Initialize & repeatedly call Relax until d[v] = δ(s, v) for all v in V. Then, G is a shortest-path tree rooted at s. Proof: Key Proof Obligation: For all v in V, the unique simple path p from s to v in G (path exists by Lemma 24.16) is a shortest path from s to v in G. Let p = ‹v0, v1, …, vk›, where v0 = s and vk = v. We have d[vi] = δ(s, vi) d[vi]  d[vi-1] + w(vi-1, vi) (reasoning as before) Implies w(vi-1, vi)  δ(s, vi) – δ(s, vi-1).
  • 14. Proof (Continued) Comp 122, Fall 2003 Single- source SPs - 14 ) v , δ(s ) v , δ(s ) v , δ(s )) v , δ(s ) v , δ(s ( ) v , w(v w(p) k 0 k 1 - i i k 1 i k 1 i i 1 i            So, equality holds and p is a shortest path.
  • 15. Bellman-Ford Algorithm Comp 122, Fall 2003 Single- source SPs - 15 Can have negative-weight edges. Will “detect” reachable negative-weight cycles. Initialize(G, s); for i := 1 to |V[G]| –1 do for each (u, v) in E[G] do Relax(u, v, w) od od; for each (u, v) in E[G] do if d[v] > d[u] + w(u, v) then return false fi od; return true Time Complexity is O(VE).
  • 16.  So if Bellman-Ford has not converged after V(G) - 1 iterations, then there cannot be a shortest path tree, so there must be a negative weight cycle. Comp 122, Fall 2003 Single- source SPs - 16
  • 17. Example Comp 122, Fall 2003 Single- source SPs - 17 0     z u v x y 6 5 –3 9 7 7 8 –2 –4 2
  • 18. Example Comp 122, Fall 2003 Single- source SPs - 18 0  7  6 z u v x y 6 5 –3 9 7 7 8 –2 –4 2
  • 19. Example Comp 122, Fall 2003 Single- source SPs - 19 0 2 7 4 6 z u v x y 6 5 –3 9 7 7 8 –2 –4 2
  • 20. Example Comp 122, Fall 2003 Single- source SPs - 20 0 2 7 4 2 z u v x y 6 5 –3 9 7 7 8 –2 –4 2
  • 21. Example Comp 122, Fall 2003 Single- source SPs - 21 0 -2 7 4 2 z u v x y 6 5 –3 9 7 7 8 –2 –4 2
  • 22. Another Look Comp 122, Fall 2003 Single- source SPs - 22 Note: This is essentially dynamic programming. Let d(i, j) = cost of the shortest path from s to i that is at most j hops. d(i, j) = 0 if i = s  j = 0  if i  s  j = 0 min({d(k, j–1) + w(k, i): i  Adj(k)}  {d(i, j–1)}) if j > 0 z u v x y 1 2 3 4 5 0 0     1 0 6  7  2 0 6 4 7 2 3 0 2 4 7 2 4 0 2 4 7 –2 j i
  • 23. Lemma 24.2 Comp 122, Fall 2003 Single- source SPs - 23 Lemma 24.2: Assuming no negative-weight cycles reachable from s, d[v] = (s, v) holds upon termination for all vertices v reachable from s. Proof: Consider a SP p, where p = ‹v0, v1, …, vk›, where v0 = s and vk = v. Assume k  |V| – 1, otherwise p has a cycle. Claim: d[vi] = (s, vi) holds after the ith pass over edges. Proof follows by induction on i. By Lemma 24.11, once d[vi] = (s, vi) holds, it continues to hold.
  • 24. Correctness Comp 122, Fall 2003 Single- source SPs - 24 Claim: Algorithm returns the correct value. (Part of Theorem 24.4. Other parts of the theorem follow easily from earlier results.) Case 1: There is no reachable negative-weight cycle. Upon termination, we have for all (u, v): d[v] = (s, v) , by lemma 24.2 (last slide) if v is reachable; d[v] = (s, v) =  otherwise.  (s, u) + w(u, v) , by Lemma 24.10. = d[u] + w(u, v) So, algorithm returns true.
  • 25. Case 2 Comp 122, Fall 2003 Single- source SPs - 25 Case 2: There exists a reachable negative-weight cycle c = ‹v0, v1, …, vk›, where v0 = vk. We have i = 1, …, k w(vi-1, vi) < 0. (*) Suppose algorithm returns true. Then, d[vi]  d[vi-1] + w(vi-1, vi) for i = 1, …, k. (because Relax didn’t change any d[vi] ). Thus, i = 1, …, k d[vi]  i = 1, …, k d[vi-1] + i = 1, …, k w(vi-1, vi) But, i = 1, …, k d[vi] = i = 1, …, k d[vi-1]. Can show no d[vi] is infinite. Hence, 0  i = 1, …, k w(vi-1, vi). Contradicts (*). Thus, algorithm returns false.
  • 26. Shortest Paths in DAGs Comp 122, Fall 2003 Single- source SPs - 26 Topologically sort vertices in G; Initialize(G, s); for each u in V[G] (in order) do for each v in Adj[u] do Relax(u, v, w) od od
  • 27. Example Comp 122, Fall 2003 Single- source SPs - 27  0     r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 28. Example Comp 122, Fall 2003 Single- source SPs - 28  0     r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 29. Example Comp 122, Fall 2003 Single- source SPs - 29  0 2 6   r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 30. Example Comp 122, Fall 2003 Single- source SPs - 30  0 2 6 6 4 r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 31. Example Comp 122, Fall 2003 Single- source SPs - 31  0 2 6 5 4 r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 32. Example Comp 122, Fall 2003 Single- source SPs - 32  0 2 6 5 3 r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 33. Example Comp 122, Fall 2003 Single- source SPs - 33  0 2 6 5 3 r s t u v w 5 2 7 –1 –2 6 1 3 2 4
  • 34. Dijkstra’s Algorithm Comp 122, Fall 2003 Single- source SPs - 34 Assumes no negative-weight edges. Maintains a set S of vertices whose SP from s has been determined. Repeatedly selects u in V–S with minimum SP estimate (greedy choice). Store V–S in priority queue Q. Initialize(G, s); S := ; Q := V[G]; while Q   do u := Extract-Min(Q); S := S  {u}; for each v  Adj[u] do Relax(u, v, w) od od
  • 35. Example Comp 122, Fall 2003 Single- source SPs - 35 0     s u v x y 10 1 9 2 4 6 5 2 3 7
  • 36. Example Comp 122, Fall 2003 Single- source SPs - 36 0  5  10 s u v x y 10 1 9 2 4 6 5 2 3 7
  • 37. Example Comp 122, Fall 2003 Single- source SPs - 37 0 7 5 14 8 s u v x y 10 1 9 2 4 6 5 2 3 7
  • 38. Example Comp 122, Fall 2003 Single- source SPs - 38 0 7 5 13 8 s u v x y 10 1 9 2 4 6 5 2 3 7
  • 39. Example Comp 122, Fall 2003 Single- source SPs - 39 0 7 5 9 8 s u v x y 10 1 9 2 4 6 5 2 3 7
  • 40. Example Comp 122, Fall 2003 Single- source SPs - 40 0 7 5 9 8 s u v x y 10 1 9 2 4 6 5 2 3 7