forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisjointSetTest.java
More file actions
34 lines (24 loc) · 789 Bytes
/
DisjointSetTest.java
File metadata and controls
34 lines (24 loc) · 789 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
31
32
33
34
package src.test.java.com.dataStructures;
import org.junit.Test;
import src.main.java.com.dataStructures.DisjointSet;
import static org.junit.Assert.*;
public class DisjointSetTest {
@Test
public void test() {
DisjointSet<Object> set = new DisjointSet<>();
set.makeSet("flink");
set.makeSet("c++");
set.makeSet("java");
set.makeSet("py");
set.makeSet("spark");
set.union("java", "c++");
assertTrue(set.isConnected("java", "c++"));
assertFalse(set.isConnected("java", "py"));
set.union("c++", "py");
assertTrue(set.isConnected("java", "py"));
set.makeSet("lisp");
set.union("lisp", "py");
assertTrue(set.isConnected("c++", "lisp"));
set.show();
}
}