MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / findSet

Method findSet

Graphs/KruskalMST.js:22–28  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

20 }
21
22 findSet(x) {
23 // Function to find the set x belongs to (with path-compression)
24 if (this.map[x] !== this.map[x].parent) {
25 this.map[x].parent = this.findSet(this.map[x].parent.key)
26 }
27 return this.map[x].parent
28 }
29
30 union(x, y) {
31 // Function to merge 2 disjoint sets

Callers 2

unionMethod · 0.95
KruskalMSTMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected