function for union of two nodes in the set kruskalsalgo
| 443 | |
| 444 | //function for union of two nodes in the set kruskalsalgo |
| 445 | void unionn(int u,int v,vector<int>&parent,vector<int>&rank){ |
| 446 | u=findpair(u,parent); |
| 447 | v=findpair(v,parent); |
| 448 | |
| 449 | if(rank[u]<rank[v]){ |
| 450 | parent[u]=v; |
| 451 | }else if(rank[v]<rank[u]){ |
| 452 | parent[v]=u; |
| 453 | }else{ |
| 454 | parent[v]=u; |
| 455 | rank[u]++; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | //function to find the parent of the node in the set kruskalsalgo |
| 460 | int findpair(int n,vector<int>&parent){ |
no test coverage detected