0% found this document useful (0 votes)
36 views4 pages

In Class Exercise 4

This document contains information about shortest path algorithms, including: 1) It describes the label correcting algorithm and provides a example network with labels. 2) It then describes a FIFO variant of the label correcting algorithm. 3) It introduces the concept of topological ordering for networks and provides pseudocode for finding the topological ordering of nodes. 4) Finally, it describes how to find the shortest path on a topologically ordered network using the labels from the previous algorithms.

Uploaded by

NabeelSaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

In Class Exercise 4

This document contains information about shortest path algorithms, including: 1) It describes the label correcting algorithm and provides a example network with labels. 2) It then describes a FIFO variant of the label correcting algorithm. 3) It introduces the concept of topological ordering for networks and provides pseudocode for finding the topological ordering of nodes. 4) Finally, it describes how to find the shortest path on a topologically ordered network using the labels from the previous algorithms.

Uploaded by

NabeelSaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

In Class Exercise 4

CE 510 Transportation Network Analysis


Department of Civil and Environmental Engineering
Portland State University

Date April 20, 2017

Shortest Path Optimality Conditions:


2
4 5

1 1 4

6 2
3

Label Correcting Algorithm:


Initialize:
Lr ← 0
Li ← ∞ ∀i ∈ N − r
pi ← −1 ∀i ∈ N
while there exists arc (i, j) ∈ A such that Lj > Li + cij do
Lj ← Li + cij
pj ← i
end while
2
4 3
−1
1 1 4 5
3
2 1
3

1
Label Correcting Algorithm FIFO Variant:
Initialize:
Lr ← 0
Li ← ∞ ∀i ∈ N − r
pi ← −1 ∀i ∈ N
Q←r
while Q 6= φ do
Select i ∈ Q
Q ← Q − {i}
for each arc (i, j) ∈ A(i) do
if Lj > Li + cij then
Lj ← Li + cij
pj ← i
if j ∈
/ Q then
Q←Q∪j
end if
end if
end for
end while
2
4 3
−1
1 1 4 5
3
2 1
3

2
Topological Order:
Initialize:
|B(i)|∀i ∈ N : Initialize the indegree of all nodes
F ← φ, ctr ← 0
for all i ∈ N do
if |B(i)| = 0 then
F =F ∪i
end if
end for
while F 6= φ do
Select i ∈ F , F = F − i, ctr ← ctr + 1
N odeN um[i] ← ctr
for each arc (i, j) ∈ A(i) do
|B(j)| ← |B(j)| − 1
if |B(j)| = 0 then
F =F ∪j
end if
end for
end while
2
4 3
−1
1 1 4 5
3
2 1
3

3
Shortest Path on Topologically Ordered Networks:
Initialize:
Lr ← 0
Li ← ∞ ∀i ∈ N − r
pi ← −1 ∀i ∈ N
NT : List of nodes sorted in increasing order of their topological node number
for each i ∈ NT do
for each arc (i, j) ∈ A(i) do
if Lj > Li + cij then
Lj ← Li + cij
pj ← i
end if
end for
end for
2
4 3
−1
1 1 4 5
3
2 1
3

You might also like