Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6e3e2b

Browse files
committed
Kosaraju.js exports function kosaraju rather than class
1 parent2754071 commite6e3e2b

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-
exportclassKosaraju{
11+
classKosaraju{
1212
constructor(graph){
1313
this.connections={}
1414
this.reverseConnections={}
@@ -80,7 +80,14 @@ export class Kosaraju {
8080
}
8181
}
8282

83-
// new Kosaraju([
83+
functionkosaraju(graph){
84+
conststronglyConnectedComponents=newKosaraju(graph)
85+
returnstronglyConnectedComponents
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
constgraph=[
@@ -10,7 +10,7 @@ test('Test Case 1', () => {
1010
[5,6],
1111
[6,4]
1212
]
13-
conststronglyConnectedComponents=newKosaraju(graph)
13+
conststronglyConnectedComponents=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-
conststronglyConnectedComponents=newKosaraju(graph)
28+
conststronglyConnectedComponents=kosaraju(graph)
2929
expect(stronglyConnectedComponents).toStrictEqual([[1,3,2],[4],[5]])
3030
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp