union-find
Advanced tools
Comparing version 1.0.1 to 1.0.2
10
index.js
@@ -31,8 +31,12 @@ "use strict"; "use restrict"; | ||
proto.find = function(x) { | ||
var x0 = x | ||
var roots = this.roots; | ||
while(roots[x] !== x) { | ||
var y = roots[x]; | ||
roots[x] = roots[y]; | ||
x = y; | ||
x = roots[x] | ||
} | ||
while(roots[x0] !== x) { | ||
var y = roots[x0] | ||
roots[x0] = x | ||
x0 = y | ||
} | ||
return x; | ||
@@ -39,0 +43,0 @@ } |
{ | ||
"name": "union-find", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A union-find data structure for maintaining disjoint sets.", | ||
@@ -28,4 +28,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "^2.12.3" | ||
"tape": "^3.5.0" | ||
} | ||
} |
6064
100