Skip to content

Commit ff6d7f6

Browse files
committed
test: add unit tests for condensation function in SCCs
1 parent 3174c61 commit ff6d7f6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Graphs/test/Condensation.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { condensation } from '../Condensation.js'
2+
3+
test('Test Case 1', () => {
4+
const graph = [
5+
[1, 2],
6+
[2, 3],
7+
[3, 1],
8+
[2, 4],
9+
[4, 5],
10+
[5, 6],
11+
[6, 4]
12+
]
13+
const { sccs } = condensation(graph)
14+
expect(sccs).toStrictEqual([
15+
[1, 3, 2],
16+
[4, 6, 5]
17+
])
18+
})
19+
20+
test('Test Case 2', () => {
21+
const graph = [
22+
[1, 2],
23+
[2, 3],
24+
[3, 1],
25+
[2, 4],
26+
[4, 5]
27+
]
28+
const { sccs } = condensation(graph)
29+
expect(sccs).toStrictEqual([[1, 3, 2], [4], [5]])
30+
})

0 commit comments

Comments
 (0)