(subset subsets[], int x, int y)
| 35 | } |
| 36 | |
| 37 | void Union(subset subsets[], int x, int y) { |
| 38 | int xroot = find(subsets, x); |
| 39 | int yroot = find(subsets, y); |
| 40 | |
| 41 | if (subsets[xroot].rank < subsets[yroot].rank) |
| 42 | subsets[xroot].parent = yroot; |
| 43 | else if (subsets[xroot].rank > subsets[yroot].rank) |
| 44 | subsets[yroot].parent = xroot; |
| 45 | else { |
| 46 | subsets[yroot].parent = xroot; |
| 47 | subsets[xroot].rank++; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Applying Krushkal Algorithm |
| 52 | void KruskalAlgo() { |