Skip to content
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

[BUG]: edge case for dfs #1722

Closed
shrivalidutt opened this issue Oct 8, 2024 · 1 comment
Closed

[BUG]: edge case for dfs #1722

shrivalidutt opened this issue Oct 8, 2024 · 1 comment

Comments

@shrivalidutt
Copy link

Description

If you start DFS with a node that doesn't exist in the graph, it will lead to an error when trying to access this.connections[currNode].

Expected Behavior

When the method is called with a valid node that exists in the graph, it should perform a depth-first search (DFS) starting from that node. It will explore all connected nodes and return true if it finds a node that matches the targetValue.

Actual Behavior

If the method was called with a node that doesn't exist in the graph:

It would attempt to access this.connections[currNode] in the while loop, leading to an error.
This would crash the method and potentially halt the program, resulting in a poor user experience.

Steps to reproduce (if applicable)

No response

Additional information

No response

@shrivalidutt shrivalidutt added the bug Something isn't working label Oct 8, 2024
@appgurueu
Copy link
Collaborator

Not a bug. If the precondition is violated, the function is allowed to crash, and this is to be expected. We could add some more error handling to throw a more useful error in this case, but I don't consider this necessary, and it would further clutter the implementation.

@appgurueu appgurueu closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
@appgurueu appgurueu removed the bug Something isn't working label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants