MCPcopy Create free account
hub / github.com/ActiveState/code / Find

Function Find

recipes/Python/577225_UnionFind/recipe-577225.py:27–32  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

25 xRoot.rank = xRoot.rank + 1
26
27def Find(x):
28 if x.parent == x:
29 return x
30 else:
31 x.parent = Find(x.parent)
32 return x.parent
33
34""""""""""""""""""""""""""""""""""""""""""
35# sample code using Union-Find (not needed)

Callers 2

UnionFunction · 0.85
recipe-577225.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected