-
Notifications
You must be signed in to change notification settings - Fork 497
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
Added Breadth-First Search [Python] #539
Conversation
Hi! Thanks for showing interest in contributing to this repository. Please make sure that you have ticked the points mentioned in PR description correctly. Thanks again! |
from collections import deque | ||
|
||
|
||
def breadth_first_search(graph, source): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SteadBytes: The breadth first search algorithm should be used for searching the path from one node to another in the graph in a breadth first manner.
In this implementation, you are trying to list out the breadth first traversal path, while you should be searching for a node.
Please let me know if something is wrong with this explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@singhpratyush That is a very good point! I guess I was trying to show how a breadth first search would traverse the structure during the search - which makes this a breadth first traversal algorithm as apposed to search.
It will be easy enough to fix though, should I fix and make a new PR or just udpate this one? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this one itself. Thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will do, I just noticed there is a directory for depth_first_traversal
, I could move this algorithm into a breadth_first_traversal
directory and then make the changes to this for breadth_first_search
.
Would that be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding breadth first traversal can go to another PR. Or you can close this PR, create another PR with different change in README and make it as breadth first traversal.
I prefer the first option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sounds good, I will do that - thanks a lot :)
Fixes #27
By submitting this pull request I confirm I've read and complied with the below declarations.
Added {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.