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
32 lines (23 loc) · 771 Bytes
/
Copy pathDisjointSetTest.java
File metadata and controls
32 lines (23 loc) · 771 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
package com.dataStructures;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class DisjointSetTest {
@Test
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++");
Assertions.assertTrue(set.isConnected("java", "c++"));
Assertions.assertFalse(set.isConnected("java", "py"));
set.union("c++", "py");
Assertions.assertTrue(set.isConnected("java", "py"));
set.makeSet("lisp");
set.union("lisp", "py");
Assertions.assertTrue(set.isConnected("c++", "lisp"));
set.show();
}
}