Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1676 +/- ##
==========================================
+ Coverage 84.65% 84.74% +0.08%
==========================================
Files 378 380 +2
Lines 19744 19850 +106
Branches 2951 2974 +23
==========================================
+ Hits 16715 16821 +106
Misses 3029 3029 ☔ View full report in Codecov by Sentry. |
| * Kahn's Algorithm is used for finding the topological sorting order of directed acyclic graph | ||
| * | ||
| * @param graph - Graph (adjacency list) | ||
| * @param n - Size of graph |
There was a problem hiding this comment.
Redundant. Just use graph.length.
| * | ||
| */ | ||
|
|
||
| export function KahnsAlgorithm(graph, n) { |
There was a problem hiding this comment.
I'd prefer calling this topoSort or similar.
| inDegree[neighbour] += 1 | ||
| } | ||
| } | ||
| const queue = new Queue() |
There was a problem hiding this comment.
Why use a queue when you can get away with just using JS data structures, specifically, a stack?
Also, why call this "queue" rather than giving it a more descriptive name like "roots"?
| const node = queue.dequeue() | ||
| result.push(node) | ||
| for (const neighbour of graph[node]) { | ||
| inDegree[neighbour] -= 1 |
There was a problem hiding this comment.
| inDegree[neighbour] -= 1 | |
| inDegree[neighbour]-- |
| result.push(node) | ||
| for (const neighbour of graph[node]) { | ||
| inDegree[neighbour] -= 1 | ||
| if (inDegree[neighbour] == 0) { |
There was a problem hiding this comment.
| if (inDegree[neighbour] == 0) { | |
| if (inDegree[neighbour] === 0) { |
| @@ -0,0 +1,13 @@ | |||
| import { kannsAlgorithm } from '../KannsAlgorithm' | |||
There was a problem hiding this comment.
You forgot to delete this file.
| @@ -0,0 +1,13 @@ | |||
| import { KahnsAlgorithm } from '../KahnsAlgorithm' | |||
|
|
|||
| test('Graph without cycle', () => { | |||
There was a problem hiding this comment.
As said, these two test blocks should be in a describe("Kahn's algorithm", () => {...}) block.
Deleted KahnaAlgorithm.js
Deleted Graphs/KannsAlgorithm.js
Graphs/test/KahnsAlgorithm.test.js
|
Hai, |
Summary
File Added