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

In graph_search there's a sub optimal algorithm for shortest path #341

Closed
keobox opened this issue Jul 15, 2020 · 4 comments
Closed

In graph_search there's a sub optimal algorithm for shortest path #341

keobox opened this issue Jul 15, 2020 · 4 comments
Labels

Comments

@keobox
Copy link

@keobox keobox commented Jul 15, 2020

find_shortest_path can be done in linear time using BFS (Breadth First Search).
The original article mentioned in the comments in graph_serach.py is providing the code using BFS.

Also all paths can be implemented with a BFS or DFS (Depth First Search).
Here some examples in Java:
https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/DepthFirstPaths.java.html
https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/BreadthFirstPaths.java.html

@faif faif added the enhancement label Jul 15, 2020
@faif
Copy link
Owner

@faif faif commented Jul 15, 2020

Feel free to open a pull request with improvements. I have my doubts about whether it's better to remove the algorithms examples from this repo, since they are not design pattern related.

@LCVcode
Copy link
Contributor

@LCVcode LCVcode commented Aug 16, 2020

I'll implement BFS in graph_search.py. The current DFS solutions are good, and I will not remove them. They'll get renamed to include "dfs" and I'll add some new methods.

@LCVcode
Copy link
Contributor

@LCVcode LCVcode commented Aug 19, 2020

@faif, this issue was resolved with PR #350, which I made. I'm new to GitHub, is there a way I could have connected that PR to this issue?

@faif
Copy link
Owner

@faif faif commented Aug 19, 2020

What you did looks fine, thanks :)

@faif faif closed this Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.