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

Method unite

CPP/Kruskal's_Algorithm.cpp:33–48  ·  view source on GitHub ↗

Union function

Source from the content-addressed store, hash-verified

31
32 // Union function
33 void unite(int x, int y)
34 {
35 int s1 = find(x);
36 int s2 = find(y);
37
38 if (s1 != s2) {
39 if (rank[s1] < rank[s2]) {
40 parent[s1] = s2;
41 rank[s2] += rank[s1];
42 }
43 else {
44 parent[s2] = s1;
45 rank[s1] += rank[s2];
46 }
47 }
48 }
49};
50
51class Graph {

Callers 1

kruskals_mstMethod · 0.80

Calls 1

findFunction · 0.50

Tested by

no test coverage detected