Skip to content

Improve dfs performance - #51

Merged
davecom merged 5 commits into
davecom:masterfrom
ferranlala:Improve-DFS-Performance
Oct 22, 2018
Merged

davecom merged 5 commits into
davecom:masterfrom
ferranlala:Improve-DFS-Performance

Conversation

@ferranlala

Copy link
Copy Markdown
Collaborator

No description provided.

@davecom

davecom commented Oct 22, 2018

Copy link
Copy Markdown
Owner

Interesting; I'm surprised moving the visited[] set has a significant impact on performance. Are we sure this won't lead to duplicate traversals in some edges cases?

@ferranlala

Copy link
Copy Markdown
Collaborator Author

I can't think of any. Plus the bfs code is already like this.
With this change we avoid pushing a vertex to the stack only to later realize that we had already pushed it before.

@davecom
davecom merged commit 2fa5a27 into davecom:master Oct 22, 2018
@davecom

davecom commented Oct 22, 2018

Copy link
Copy Markdown
Owner

Cool, thanks for the explanation and great contribution!

@ferranlala ferranlala mentioned this pull request Oct 27, 2018
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