0% found this document useful (0 votes)
19 views3 pages

In Class Exercise 2

The document provides pseudocode for Dijkstra's algorithm and a variant of Dijkstra's algorithm to solve the single-source shortest path problem on a graph. The algorithms initialize labels and sets, then iterate through arcs to update labels and track explored nodes until all nodes have been reached. The variant modifies the order of node selection by choosing the node with the minimum label from the unexplored set on each iteration.

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)
19 views3 pages

In Class Exercise 2

The document provides pseudocode for Dijkstra's algorithm and a variant of Dijkstra's algorithm to solve the single-source shortest path problem on a graph. The algorithms initialize labels and sets, then iterate through arcs to update labels and track explored nodes until all nodes have been reached. The variant modifies the order of node selection by choosing the node with the minimum label from the unexplored set on each iteration.

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/ 3

In Class Exercise 2

CEE 510 Transportation Network Analysis


Department of Civil and Environmental Engineering
Portland State University

Date April 13, 2017

Initialize:
Lr ← 0
Li ← ∞ ∀i ∈ N − r
F ←r
pi ← −1 ∀i ∈ N
while |F | < n do
S = {(i, j) ∈ A : i ∈ F, j ∈/ F }: Set of all admissable arcs
for each arc (i, j) ∈ S do
Determine temporary label Ltij ← Li + cij
end for
Determine (i∗ , j ∗ ) with minimum value of Ltij
Lj ∗ ← Lti∗ j ∗
F ← F ∪ j∗
pj ∗ ← i∗
end while
Algorithm 1: Dijkstra’s Algorithm
2
4 5

1 1 4

6 2
3

1
Initialize:
Lr ← 0
Li ← ∞ ∀i ∈ N − r
F ← φ,T ← N
pi ← −1 ∀i ∈ N
while |F | < n do
Determine node i ∈ T with minimum value of Li
for each arc (i, j) ∈ A(i) do
Ltij ← Li + cij
if Ltij < Lj then
Lj ← Ltij
pj ← i
end if
end for
F ←F ∪i
T ←T −i
end while
Algorithm 2: Dijkstra’s Algorithm Variant
2
4 5

1 1 4

6 2
3

2
4
1 2
2
6

4 3
−9
1

You might also like