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

Raisah #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Raisah #17

wants to merge 1 commit into from

Conversation

rvesteinsdottir
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good DFS implementation, although I'm uncertain if this will solve in the general-case. What if the 1st node the stack starts with has a subgraph which works, but there is another disconnected subgraph that doesn't?

visited = []
stack.push(i)

until stack.empty?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a depth first search here, but how would this work for a disconnected graph? I think may only be satisfying the tests based on the fact that you're starting with the first node that has a connection.

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

Successfully merging this pull request may close these issues.

2 participants