lecture 10 the label correcting algorithm

51
Lecture 10 The Label Correcting Algorithm

Upload: hugh-riley

Post on 01-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Lecture 10

The Label Correcting Algorithm

Label Correcting Algorithm

An Example

3

Initialize

d(1) := 0; d(j) := for j 1

1

2 4

5

3 6

7

2

331

6 -2

32

-443

0

In next slides: the number inside the node will be d(j).

Violating arcs will be in thick lines.

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

4

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

4

6

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

4

62

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

4

62

9

An Example

3

Generic Step

An arc (i,j) is violating if d(j) > d(i) + cij.

0

2

331

6 -2

32

-443

Pick a violating arc (i,j) and replace d(j) by d(i) + cij.

3

6

3

5

4

62

9

No arc is violating

The distance labels are optimal

We now show the predecessor arcs.

Modified Label Correcting Algorithm

The Modified Label Correcting Algorithm

3

Initialize

d(1) := 0; d(j) := for j 1

1

2 5

4

3 6

7

2

331

6 -2

32

-443

0

In next slides: the number inside the node will be d(j).

LIST := {1}

LIST := { 1 }

An Example

3

Generic Step

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3LIST := {1}LIST := { }

6

LIST := { 2 }LIST := { 2, 3 }

3

LIST := { 2, 3, 4 }

0

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3LIST := {1}LIST := { }

6

LIST := { 2 }LIST := { 2, 3 }

3

LIST := { 2, 3, 4 } 3LIST := { 3, 4 }

4

5LIST := { 3, 4, 5 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }

3

LIST := { 4, 5 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }

4

LIST := { 5 }

6

LIST := { 5, 6 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }LIST := { 5 }

6

LIST := { 5, 6 } 5LIST := { 6 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }LIST := { 5 }

6

LIST := { 5, 6 }LIST := { 6 }

6

LIST := { }

2

LIST := { 3 }

9

LIST := { 3, 7 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }LIST := { 5 }

6

LIST := { 5, 6 }LIST := { 6 }LIST := { }

2

LIST := { 3 }

9

LIST := { 3, 7 }

2

LIST := { 7 }

An Example

3

Take a node i from LIST

0

2

331

6 -2

32

-443

Update(i): for each arc (i,j) with d(j) > d(i) + cij

replace d(j) by d(i) + cij.

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }LIST := { 5 }

6

LIST := { 5, 6 }LIST := { 6 }LIST := { }

2

LIST := { 3 }

9

LIST := { 3, 7 }LIST := { 7 }

9

LIST := { }

An Example

3

LIST is empty.

The distance labels are optimal

0

2

331

6 -2

32

-443

3

6

3

4

5LIST := { 3, 4, 5 }LIST := { 4, 5 }LIST := { 5 }

6

LIST := { 5, 6 }LIST := { 6 }LIST := { }

2

LIST := { 3 }

9

LIST := { 3, 7 }LIST := { 7 }LIST := { }

Here are the predecessors