MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / unionn

Function unionn

CPP/graphseries.cpp:445–457  ·  view source on GitHub ↗

function for union of two nodes in the set kruskalsalgo

Source from the content-addressed store, hash-verified

443
444//function for union of two nodes in the set kruskalsalgo
445void 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
460int findpair(int n,vector<int>&parent){

Callers 1

kruskalsAlgoFunction · 0.70

Calls 1

findpairFunction · 0.85

Tested by

no test coverage detected