| 38 | } |
| 39 | |
| 40 | void make_union(vector<int> &parent, vector<int> &rank, int a, int b) |
| 41 | { |
| 42 | int first_parent = find(parent, a); |
| 43 | int second_parent = find(parent, b); |
| 44 | |
| 45 | if (first_parent == second_parent) |
| 46 | { |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | if (rank[first_parent] < rank[second_parent]) |
| 51 | { |
| 52 | parent[first_parent] = second_parent; |
| 53 | } |
| 54 | else if (rank[first_parent] > rank[second_parent]) |
| 55 | { |
| 56 | parent[second_parent] = first_parent; |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | parent[first_parent] = second_parent; |
| 61 | rank[second_parent]++; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void kruskal(vector<pair<int, int>> vec[], int v) |
| 66 | { |