Skip to content

Added: Tarjan's SCC algorithm and test cases #1774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added a few edge test cases
  • Loading branch information
vedas-dixit committed Apr 15, 2025
commit ae3b7fb135f01507162c714788919ada3dcada94
20 changes: 20 additions & 0 deletions Graphs/test/TarjanSCC.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,23 @@ test('Test Case 4 - Complex Graph', () => {

expect(actual).toEqual(expect.arrayContaining(expected))
})

test('Edge Case - Null input should throw error', () => {
expect(() => TarjanSCC(null)).toThrow(
'Graph must be a non-null object representing an adjacency list'
)
})

test('Edge Case - Node with non-array neighbors should throw error', () => {
const graph = {
A: 'not-an-array'
}
expect(() => TarjanSCC(graph)).toThrow('Neighbors of node A must be an array')
})

test('Edge Case - Neighbor not in graph should throw error', () => {
const graph = {
A: ['B']
}
expect(() => TarjanSCC(graph)).toThrow('Node B not found in graph')
})
Loading