Download presentation

Presentation is loading. Please wait.

Published byIsaac Love Modified over 3 years ago

1
Calcolo delle componenti connesse A B A C D F E BCDEF X = {[A,B], [C,F], [E,D], [A,D], [B,E], [A,E]} For v = 1 to n do MakeSet(v) p = [1 2 3 4 5 6] rank = [0 0 0 0 0 0]

2
Calcolo delle componenti connesse ABCDEF For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) [A,B] r = FindSet(A) = A s = FindSet(B) = B Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++ p = [1 1 3 4 5 6] rank = [1 0 0 0 0 0] B A C D F E

3
Calcolo delle componenti connesse ABCDEF [C,F] r = FindSet(C) = C s = FindSet(F) = F p = [1 1 3 4 5 3] rank = [1 0 1 0 0 0] B A C D F E For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++

4
Calcolo delle componenti connesse ABCDEF [E,D] r = FindSet(E) = E s = FindSet(D) = D p = [1 1 3 4 4 3] rank = [1 0 1 1 0 0] B A C D F E For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++

5
Calcolo delle componenti connesse ABCDEF [A,D] r = FindSet(A) = A s = FindSet(D) = D p = [1 1 3 1 4 3] rank = [2 0 1 1 0 0] B A C D F E For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++

6
Calcolo delle componenti connesse ABCDEF [B,E] r = FindSet(B) = A s = FindSet(E) = A p = [1 1 3 1 4 3] rank = [2 0 1 1 0 0] B A C D F E For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++

7
Calcolo delle componenti connesse ABCDEF [A,E] r = FindSet(A) = A s = FindSet(E) = A p = [1 1 3 1 4 3] rank = [2 0 1 1 0 0] B A C D F E For each [u,v] E do r = FindSet(u) s = FindSet(v) If r s then Union(r,s) Union(r,s) If rank[r] < rank[s] then p[r] = s else p[s] = r If rank[r] = rank[s] rank[r]++

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google