Kraskal Algorithm - building an optimal framework

19 , , . : , n . 20 . , . .

""

"" ( ). – . "" . , , . . .

. . , w, e – – w(e). . .

. . , . , , . . , , . , – . , , – . , , , . . .





F. ( F, ). . Part(x) – , x , x. Unite(x,y) – , , x y . n – . . :

  1. 1- n- . (ai, bi – i).

  2. for i = 1 to n do.

  3. x := Part(ai).

  4. y : = Part(bi).

  5. If x y then Unite (x, y), F i.

T – , , S – . , w(T) w(S).

M – S, P – T. S T, et T, S. et S. , C. C es, S. , , . w(S), w(et) w(es) . ( S T) , . , , w(T) , w(S).





- .

Kraskal algorithm




a, b, c, d, e (a, b), (a, e), (b, c), (b, e), (c, d), (c, e), (d, e). . F . (a, e), , a e F ( (a, e) ), (c, d), , F, , (a, b). (b, e) , , : b e F, F (b, e), . (b, c), (c, e), d, e. , (a, e), (c, d), (a, b), (b, c). . . .

Kraskal algorithm example




, . (), .

Kraskal algorithm implementation




, - , .

: (1,6); (0,3), (2,6) (2,6), (0,3) – ; (3,4); (0,1), (1,6) (1,6), (0,1), (5,6).

the correctness of the Kruskal algorithm




, , , , .




All Articles