Download presentation

Presentation is loading. Please wait.

Published byIsaac Love Modified over 2 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 = [ ] rank = [ ]

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 = [ ] rank = [ ] B A C D F E

3
Calcolo delle componenti connesse ABCDEF [C,F] r = FindSet(C) = C s = FindSet(F) = F p = [ ] rank = [ ] 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 = [ ] rank = [ ] 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 = [ ] rank = [ ] 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 = [ ] rank = [ ] 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 = [ ] rank = [ ] 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

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google