Skip to content

[BUG]: edge case for dfs #1722

@shrivalidutt

Description

@shrivalidutt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions