-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (23 loc) · 723 Bytes
/
Main.java
File metadata and controls
30 lines (23 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.*;
import DisjointSet.DisjointSetByRank;
import DisjointSet.DisjointSet;
class Main {
public static void main(String[] args) {
var dsByRank = new DisjointSetByRank(5);
dsByRank.union(0, 3);
dsByRank.union(0, 5);
dsByRank.union(2, 3);
dsByRank.union(2, 5);
dsByRank.union(1, 4);
System.out.println(dsByRank.size(0));
System.out.println(Arrays.toString(dsByRank.parent));
var ds = new DisjointSet(5);
ds.union(0, 3);
ds.union(0, 5);
ds.union(2, 3);
ds.union(2, 5);
ds.union(1, 4);
System.out.println(ds.size(0));
System.out.println(Arrays.toString(ds.parent));
}
}