Skip to content

Commit 80f86d1

Browse files
committed
stdlib: Make union-find not create loops when unifying two already-unified sets
1 parent 537d879 commit 80f86d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/ufind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn union(&ufind ufnd, uint m, uint n) {
3838
auto n_root = find(ufnd, n);
3939
if (m_root < n_root) {
4040
ufnd.nodes.(n_root) = some[uint](m_root);
41-
} else {
41+
} else if (m_root > n_root) {
4242
ufnd.nodes.(m_root) = some[uint](n_root);
4343
}
4444
}

0 commit comments

Comments
 (0)