We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a195f3 commit 30f4ab8Copy full SHA for 30f4ab8
src/graphs/searching/weightquickunion.js
@@ -22,7 +22,10 @@ function QuickUnion(n) {
22
* @return {number} The root of the node
23
*/
24
QuickUnion.prototype._root = function (i) {
25
- while (i !== this._ids[i]) i = this._ids[i];
+ while (i !== this._ids[i]) {
26
+// this._ids = this._ids[this._ids[i]]; //enables the path compression
27
+ i = this._ids[i];
28
+ }
29
return i;
30
};
31
0 commit comments