File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ export function KahnsAlgorithm(graph, n) {
18
18
if ( n === null || n === undefined ) throw Error ( 'Invalid n was given' )
19
19
const inDegree = Array ( n ) . fill ( 0 )
20
20
const result = [ ]
21
- for ( const neigbhours of graph ) {
22
- for ( const neigbhour of neigbhours ) {
23
- inDegree [ neigbhour ] += 1
21
+ for ( const neighbours of graph ) {
22
+ for ( const neighbour of neighbours ) {
23
+ inDegree [ neighbour ] += 1
24
24
}
25
25
}
26
26
const queue = new Queue ( )
@@ -33,10 +33,10 @@ export function KahnsAlgorithm(graph, n) {
33
33
while ( queue . length !== 0 ) {
34
34
const node = queue . dequeue ( )
35
35
result . push ( node )
36
- for ( const neigbhour of graph [ node ] ) {
37
- inDegree [ neigbhour ] -= 1
38
- if ( inDegree [ neigbhour ] == 0 ) {
39
- queue . enqueue ( neigbhour )
36
+ for ( const neighbour of graph [ node ] ) {
37
+ inDegree [ neighbour ] -= 1
38
+ if ( inDegree [ neighbour ] == 0 ) {
39
+ queue . enqueue ( neighbour )
40
40
}
41
41
}
42
42
}
You can’t perform that action at this time.
0 commit comments