lect20-label

Lecture 10
The Label Correcting Algorithm
Label Correcting Algorithm
An Example


2
4
2
3
Initialize
d(1) := 0;
d(j) :=  for j  1
0
6
1
3
3
1


7
-2
5
3
2
4
3
-4
3

6

In next slides: the number inside the node will be d(j).
Violating arcs will be in thick lines.
An Example
2


3
3
Generic Step
6
0
-2

3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

-4

3

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2


3
3
Generic Step
6
0
-2

6
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

-4

3

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2


3
3
Generic Step
6
0
-2

6
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
-4

3

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
-4

3

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
4
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
-4

3

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
4
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
-4

3

6
Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
4
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
2
-4

3

6
Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
4
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
2
-4

9
3

6
Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
An Example
2

5

3
3
Generic Step
6
0
-2

6
4
3
An arc (i,j) is
violating if
d(j) > d(i) + cij.
3
3
1
2
4

3
2
-4

9
3

6
Pick a violating arc (i,j) and replace d(j) by d(i) + cij.
No arc is violating
The distance labels are optimal
We now show the
predecessor arcs.
Modified Label Correcting Algorithm
The Modified Label Correcting Algorithm


2
5
2
3
Initialize
d(1) := 0;
d(j) :=  for j  1
0
6
1
3
3
1


7
-2
4
3
2
4
3
-4
3

6

LIST := {1}
In next slides: the number inside the node will be d(j).
An Example
2
3
6
3
3
1
0
-2

6
3
Generic Step
Take a node i
from LIST


3
LIST := {{1}
}1 }3,
2
2,
3 }4 }
2
4

3
-4

3

Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := {{1}
} }4,
2
2,
3,
3 }5
3,
4
4}
2
4

3
-4

3

Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { 4,
5 }5 }
3, 4,
2
4

3
-4

3

Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { 5,
4,
5
5 }5 }
6
3,}4,
2
4

3
-4

3

6
Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { 6
4,
5
5,
5 }5 }
6
3,}4,
2
4

3
-4

3

6
Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { 3,
4,}4,
5
5,
}6
3
5 }5 }
6
7
2
4

3
2
-4

9
3

6
Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { 7
4,}4,
5
5,
}6
3
3,
5 }5 }
6
7
2
4

3
2
-4

9
3

6
Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
Take a node i
from LIST

5

3
LIST := { }7
4,}4,
5
5,
6
3
3,
5 }5 }
6
7
2
4

3
2
-4

9
3

6
Update(i): for each arc (i,j) with d(j) > d(i) + cij
replace d(j) by d(i) + cij.
An Example
2
3
6
3
3
1
0
-2

6
4
3
LIST is empty.

5

3
LIST := { }7
4,}4,
5
5,
6
3
3,
5 }5 }
6
7
2
4

3
2
The distance labels
are optimal
Here are the predecessors
-4

9
3

6