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

Method apply_union

Python/Kruskal's_Algorithm.py:19–28  ·  view source on GitHub ↗
(self, parent, rank, x, y)

Source from the content-addressed store, hash-verified

17 return self.find(parent, parent[i])
18
19 def apply_union(self, parent, rank, x, y):
20 xroot = self.find(parent, x)
21 yroot = self.find(parent, y)
22 if rank[xroot] < rank[yroot]:
23 parent[xroot] = yroot
24 elif rank[xroot] > rank[yroot]:
25 parent[yroot] = xroot
26 else:
27 parent[yroot] = xroot
28 rank[xroot] += 1
29
30 # Applying Kruskal algorithm
31 def kruskal_algo(self):

Callers 1

kruskal_algoMethod · 0.95

Calls 1

findMethod · 0.95

Tested by

no test coverage detected