Professional Documents
Culture Documents
b 4 a 8 c 9 2 1 10 8 9 8 c 2 1 d 9 f 7 5 2 f 8 d 10 7 9 5 2 e 6 g Connected graph
b 4 a
e 6 g
17
b 4 a 8 c 9 2 8
10 7 d 9
e 6 5 2 f g
1 10 8 7 d 2 9 1
b 4 a 8 c 9
e 6 5 2 f g
Step 1.1 after S={a,b} V \ S = {c,d,e,f,g} A={{a,b}} lightest edge = {b,d}, {a,c}
18
b 4 a 8 c 9 2 8
10 7 d 9
e 6 5 2 f g
Step 1.2 before S={a,b} V \ S = {c,d,e,f,g} A={{a,b}} lightest edge = {b,d}, {a,c}
1 10 8 7 d 2 9 1
b 4 a 8 c 9
e 6 5 2 f g
19
b 4 a
e 6 g
20
b 4 a 8 c 9 2 8
10 7 d 9
e 6 5 2 f g
1 10 8 7 d 2 9 1
b 4 a 8 c 9
e 6 5 2 f g
21
b 4 a 8 c 9 2 8
10 7 d 9
e 6 5 2 f g
1 10 8 7 d 2 9 1
b 4 a 8 c 9
e 6 5 2 f g
Step 1.5 after S={a,b,c,d,f,g} V \ S = {e} A={{a,b},{b,d},{c,d},{c,f}, {f,g}} lightest edge = {f,e}
22
b 4 a 8 c 9 2 8
10 7 d 9
e 6 5 2 f g
1 10 8 7 d 2 9 1
Step 1.6 before S={a,b,c,d,f,g} V \ S = {e} A={{a,b},{b,d},{c,d},{c,f}, {f,g}} lightest edge = {f,e} Step 1.6 after S={a,b,c,d,e,f,g} V \ S = {} A={{a,b},{b,d},{c,d},{c,f}, {f,g},{f,e}} MST completed
b 4 a 8 c 9
e 6 5 2 f g
23
and
Step 1: Find a lightest edge such that one endpoint is in and the other is in . Add this edge to and its (other) endpoint to . Step 2: If , then stop and output the minimum span
. ning tree
Otherwise go to Step 1.
Questions:
How does the algorithm nd the lightest edge and update efciently? How does the algorithm update
efciently?
24