Skip to content

Commit e6e3e2b

Browse files
committed
Kosaraju.js exports function kosaraju rather than class
1 parent 2754071 commit e6e3e2b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Graphs/Kosaraju.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010

11-
export class Kosaraju {
11+
class Kosaraju {
1212
constructor (graph) {
1313
this.connections = {}
1414
this.reverseConnections = {}
@@ -80,7 +80,14 @@ export class Kosaraju {
8080
}
8181
}
8282

83-
// new Kosaraju([
83+
function kosaraju (graph) {
84+
const stronglyConnectedComponents = new Kosaraju(graph)
85+
return stronglyConnectedComponents
86+
}
87+
88+
export { kosaraju }
89+
90+
// kosaraju([
8491
// [1, 2],
8592
// [2, 3],
8693
// [3, 1],

Graphs/test/Kosaraju.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Kosaraju } from '../Kosaraju.js'
1+
import { kosaraju } from '../Kosaraju.js'
22

33
test('Test Case 1', () => {
44
const graph = [
@@ -10,7 +10,7 @@ test('Test Case 1', () => {
1010
[5, 6],
1111
[6, 4]
1212
]
13-
const stronglyConnectedComponents = new Kosaraju(graph)
13+
const stronglyConnectedComponents = kosaraju(graph)
1414
expect(stronglyConnectedComponents).toStrictEqual([
1515
[1, 3, 2],
1616
[4, 6, 5]
@@ -25,6 +25,6 @@ test('Test Case 2', () => {
2525
[2, 4],
2626
[4, 5]
2727
]
28-
const stronglyConnectedComponents = new Kosaraju(graph)
28+
const stronglyConnectedComponents = kosaraju(graph)
2929
expect(stronglyConnectedComponents).toStrictEqual([[1, 3, 2], [4], [5]])
3030
})

0 commit comments

Comments
 (0)