Mathematics FOR Efficiency: Graph Theory: Traversing The Shortest Path Problem
Mathematics FOR Efficiency: Graph Theory: Traversing The Shortest Path Problem
TRAVERSING THE
SHORTEST PATH PROBLEM
MATHEMATICS
FOR
EFFICIENCY
DESTINATION
STARTING POINT
What is the
shortest
path from
the starting
point to the
destination
point?
Moreover, there is a
loop at vertex .
If a graph contains multiple edges or loops,
then is called a multigraph. Otherwise, is
called a simple graph.
The walk is
illustrated as (check animation).
A walk of length from vertex to vertex is a
sequence of vertices such that two
consecutive vertices are joined by an edge.
Denote this walk by
( ,?) 9 b ( ,?)
CURRENT DISTANCE
a 6 VERTEX FROM
2 STARTING
14 ( ,?) VERTEX
e 11 s 0
9 ( ,?)
c
(0,*) s
10
Current vertex
15
7
f
( ,?)
To each vertex adjacent to the current vertex, update distance
value.
Among the temporary vertices (this may or may not be adjacent to
the current vertex), choose the one with the lowest distance value.
The one with the lowest distance value becomes permanent and
becomes the new current vertex.
(( ,?)
,s) 9 b ( ,?)
CURRENT DISTANCE
a 6 VERTEX FROM
2 STARTING
14 (( ,s)
,?) VERTEX
e 11 s 0
9 ( ,?)
c
(0,*) s f 7
10
15
7
f
,?) Current Vertex
(( ,s)
To each temporary vertex adjacent to the current vertex, add the distance value of
the current vertex to the weight of edge joining an adjacent vertex. If the sum the
lower, update distance value of the adjacent vertex. Otherwise, do not update.
Among the temporary vertices (this may or may not be adjacent to the current
vertex), choose the one with the lowest distance value.
The one with the lowest distance value becomes permanent and becomes the new
current vertex.
9 b ( ,?)
( ,s)
CURRENT DISTANCE
a 6 VERTEX FROM
2 Current
( ,f)=(17,f)
Vertex STARTING
14 ( ,s) ( ,f)=(22,f) VERTEX
e 11 (22,f) s 0
9 ( ,?)
c
(0,*) s f 7
10 e 9
15
7
f
( ,s)
To each temporary vertex adjacent to the current vertex, add the distance value of
the current vertex to the weight of edge joining an adjacent vertex. If the sum the
lower, update distance value of the adjacent vertex. Otherwise, do not update.
Among the temporary vertices (this may or may not be adjacent to the current
vertex), choose the one with the lowest distance value.
The one with the lowest distance value becomes permanent and becomes the new
current vertex.
(9+2,e)=(11,e)
CURRENT DISTANCE
9 b ( ,t)
( ,s)
(11,e) VERTEX FROM
a 6 STARTING
Current vertex VERTEX
2
14 (9,s) s 0
e 11 (9+11,e)=(20,e)
9 f 7
c (20,e)
(22,f)
(0,*) s e 9
10 a 11
15
7
f
( ,s)
To each vertex adjacent to the current vertex, add the distance value of the
current vertex to the weight of edge joining an adjacent vertex. If the sum the
lower, update distance value of the adjacent vertex. Otherwise, do not update.
Among the temporary vertices (this may or may not be adjacent to the current
vertex), choose the one with the lowest distance value.
The one with the lowest distance value becomes permanent and becomes the
new current vertex.
(11+9,a)=(20,a)
(20,a)
9 b ( ,?) CURRENT DISTANCE
(11,e)
VERTEX FROM
a 6 STARTING
2 VERTEX
14 (9,s)
Current Vertex s 0
e 11
9 c (20,e) f 7
(0,*) s e 9
10
a 11
15
7 c 20
f
( ,s)
CURRENT DISTANCE
VERTEX FROM
(20+6,e)=(26,e) STARTING
VERTEX
9 b (20,a)
(11,e) s 0
a 6 f 7
2 e 9
14 (9,s)
e 11 a 11
9 c (20,e) c 20
(0,*) s
10 b 20
15
7
f
( ,s)
CURRENT DISTANCE
VERTEX FROM
STARTING
VERTEX
9 b (20,a)
(11,e) s 0
a 6 f 7
2 e 9
14 (9,s)
e 11 a 11
9 c (20,e) c 20
(0,*) s
10 b 20
15
7
f
( ,s)
2
a b
3 8
6 7 1
s c
4 4
e f
5
2
a b
3 8
6 7 1
(0,*) s c
4 4
e f
5
Current Vertex Distance from s
s 0
(∞,?) (∞,?)
2
a b
3 8
6 7 1
(0,*) s c (∞,?)
Current Vertex
4 4
e f
5
(∞,?) (∞,?)
Current Vertex Distance from s
s 0
a 3
Current Vertex
(∞,?)
(3,s) (∞,?)
2
a b
3 8
6 7 1
(0,*) s c (∞,?)
4 4
e f
5
(4,s)
(∞,?) (∞,?)
(3,s) (∞,?)
2
a b
3 8
6 7 1
(0,*) s c (∞,?)
4 4
e f
5
(4,s) (∞,?)
Current Vertex Distance from s
s 0
a 3
e 4
(3,p) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,?)
4 4
e f
5
(4,s)
(4,s) (10,a)
Current Vertex
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,?)
4 4
e f
5
(4,s) (10,a)
Current Vertex
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,t)
4 4
e f
5
(4,s) (10,a)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,t)
4 4
e f
5
(4,s) (9,e)
Current Vertex Distance from s
s 0
a 3
e 4
b 5
Current Vertex
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,t)
4 4
e f
5
(4,s) (9,e)
Current Vertex
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,t)
4 4
e f
5
(4,s) (9,e)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (∞,t)
4 4
e f
5
(4,s) (9,e)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (13,b)
4 4
e f
5
(4,s) (6,b)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (13,b)
4 4
e f
5
(4,s) (6,b)
Current Vertex Distance from s
s 0
a 3
e 4
b 5
f 6
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (13,b)
4 4
e f
5
(4,s) (6,b)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (13,b)
4 4
e f
5
(4,s) (6,b)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (10,f)
4 4
e f
5
(4,s) (6,b)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (10,f)
4 4
e f
5
(4,s) (6,b)
Current Vertex Distance from s
s 0
a 3
e 4
b 5
f 6
c 10
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (10,f)
4 4
e f
5
(4,s) (6,b)
(3,s) (5,a)
2
a b
3 8
6 7 1
(0,*) s c (10,f)
4 4
e f
5
(4,s) (6,b)
1. Find the least expensive route from I to L and state its cost.
120
J K
150 80
L
I 40 100 50
120 N 30
70
40
P
30 M
30
80
O
2. Find the shortest path from vertex A to vertex Z.