MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / Union

Method Union

Programs/Kruskal.java:37–49  ·  view source on GitHub ↗
(subset subsets[], int x, int y)

Source from the content-addressed store, hash-verified

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() {

Callers 1

KruskalAlgoMethod · 0.95

Calls 1

findMethod · 0.95

Tested by

no test coverage detected