mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 07:29:47 +08:00

* kosaraju test added * Fixes: #1214 * Fixes: #1214 * Update package-lock.json * Kosaraju.js exports function kosaraju rather than class
31 lines
563 B
JavaScript
31 lines
563 B
JavaScript
import { kosaraju } from '../Kosaraju.js'
|
|
|
|
test('Test Case 1', () => {
|
|
const graph = [
|
|
[1, 2],
|
|
[2, 3],
|
|
[3, 1],
|
|
[2, 4],
|
|
[4, 5],
|
|
[5, 6],
|
|
[6, 4]
|
|
]
|
|
const stronglyConnectedComponents = kosaraju(graph)
|
|
expect(stronglyConnectedComponents).toStrictEqual([
|
|
[1, 3, 2],
|
|
[4, 6, 5]
|
|
])
|
|
})
|
|
|
|
test('Test Case 2', () => {
|
|
const graph = [
|
|
[1, 2],
|
|
[2, 3],
|
|
[3, 1],
|
|
[2, 4],
|
|
[4, 5]
|
|
]
|
|
const stronglyConnectedComponents = kosaraju(graph)
|
|
expect(stronglyConnectedComponents).toStrictEqual([[1, 3, 2], [4], [5]])
|
|
})
|