Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 57

Shortest Path in weighted

graph
Weighted Graphs
Shortest Path in Weighted graphs
Shortest Path Problems
Negative Edge Weight
Summary
Single Source Shortest Path
Single Source Shortest Path
Single Source Shortest Path
Single source shortest paths

3
70
8
0 4
1 2 50
10 5
6
20
6
7

10 5
Single source shortest paths

3
70
8
0 4
1 2 50
10 5
t= 6
20
0 6
7

10 5
Single source shortest paths

3
70
8
0 4
1 2 50
10 5
t= 6
20 t=
0 6
10 7

10 5
Single source shortest paths
t = 16

3
70
8 6
0 4
1 2 50
1 2 5
t= 0 0
0 t= 6
10 7

10 5
Single source shortest paths
t = 16
70
3
8 t = 30
64
0
1 2 50
1 2 5
t= 0 0
0 t= 6
10 7

10 5
Single source shortest paths
t = 16
70
3
8 t=
64
0 30
50
1 2 5
1 2
t= 0 0 1 6
0 t=
10 0
5
t =7
40
Single source shortest paths
t = 16
70
3
8 t= t=
64
0 30 45
50
1 2 5
1 2
t= 0 0 1 6
0 t=
10 0
5
t =7
40
Single source shortest paths
t = 16 t=
86
7
3
8 0 t= t=
4 6
0 30 45
5
1 2 5 0 6
1 2
t= 0 0 1 5
0 t=
10 0 7

t=
40
Single source shortest paths
Compute expected time to burn of each
vertex

Update this each time a new vertex burns

3
70
8
0 4
1 2 50
10 5
6
20
6
7

10 5
Single source shortest paths
Compute expected time to burn of each
vertex

Update this
∞ each time a∞new vertex burns
3
70 4
8 6 ∞ ∞
0 50
1 2 5
1 2 6
∞ ∞
0 0 1 5
0 7

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
∞ each time a∞new vertex burns
3
70 4
8 6 ∞ ∞
0 50
1 2 5
1 2 6
0 ∞
0 0 1 5
0 7

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
80each time a∞new vertex burns
3
70
4
8
∞ ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
80each time a∞new vertex burns
3
70
4
8
∞ ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a∞new vertex burns
3
70
4
8
30 ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a∞new vertex burns
3
70
4
8
30 ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
30 ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
30 ∞
0 6 50
1 2 5
1 2 6
0 1
0 0
0
10 7 5

Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
0 6 30 80
1 2 50
1 2 5
0 1
0 0 6
0
7
10 4 5
0
Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
0 6 30 80
1 2 50
1 2 5
0 1
0 0 6
0
7
10 4 5
0
Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
0 6 30 45
1 2 50
1 2 5
0 1
0 0 6
0
7
10 4 5
0
Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
0 6 30 45
1 2 50
1 2 5
0 1
0 0 6
0
7
10 4 5
0
Single source shortest paths
Compute expected time to burn of each
vertex

Update this
16each time a new vertex burns
86
3
70 4
8
0 6 30 45
1 2 50
1 2 5
0 1
0 0 6
0
7
10 4 5
0
Dijkstra’s Algorithm: Proof of Correctness
Implementation
Complexity
Summary
Single Source Shortest Path
with Negative Weight
Dijkstra’s Algorithm
Correctness requires non-negative edge
weights
Extending to negative edge weights
Extending to negative edge weights
Bellman-Ford Algorithm
Bellman-Ford Algorithm
Bellman-Ford Algorithm
Complexity
Complexity
Summary
All Pair Shortest Path
Shortest path in weighted graphs
Transitive Closure
Warshall’s Algorithm
Floyd Warshall’s Algorithm
Floyd Warshall’s Algorithm
Floyd Warshall’s Algorithm
Floyd Warshall’s Algorithm
Floyd Warshall’s Algorithm
Implementation
Summary

You might also like