21.11.2014 Views

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Now T contains {1, 2, 0}. Vertex 6 is the one in V-T with the smallest cost, so add 6 to T, as shown in<br />

Figure <strong>25</strong>.15 <strong>and</strong> update the cost <strong>and</strong> parent for vertices in V-T <strong>and</strong> adjacent to 6 if applicable.<br />

Figure <strong>25</strong>.15<br />

Now vertices {1, 2, 0, 6} are in set T.<br />

2<br />

T<br />

5<br />

8<br />

1<br />

9<br />

10<br />

5<br />

6<br />

8<br />

3<br />

8<br />

4<br />

cost<br />

6 0 5 10 10 8<br />

0 1 2 3 4 5 6<br />

parent<br />

1<br />

2<br />

7<br />

5<br />

2 -1 1 1 0 1<br />

0<br />

4<br />

5<br />

0 1 2 3 4 5 6<br />

(a)<br />

(b)<br />

Now T contains {1, 2, 0, 6}. Vertex 3 or 5 is is the one in V-T with the smallest cost. You may add<br />

either 3 or 5 into T. Let us add 3 to T, as shown in Figure <strong>25</strong>.16 <strong>and</strong> update the cost <strong>and</strong> parent for vertices<br />

in V-T <strong>and</strong> adjacent to 3 if applicable. cost[4] is now updated to 18 <strong>and</strong> its parent is set to 3.<br />

2<br />

5<br />

T<br />

8<br />

1<br />

9<br />

10<br />

5<br />

6<br />

8<br />

3<br />

8<br />

4<br />

cost<br />

6 0 5 10 18 10 8<br />

0 1 2 3 4 5 6<br />

parent<br />

1<br />

2<br />

7<br />

5<br />

2 -1 1 1 3 0 0<br />

0<br />

4<br />

5<br />

0 1 2 3 4 5 6<br />

(a)<br />

(b)<br />

Figure <strong>25</strong>.16<br />

Now vertices {1, 2, 0, 6, 3} are in set T.<br />

31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!