Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upIn graph_search there's a sub optimal algorithm for shortest path #341
Comments
|
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. |
|
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. |
|
What you did looks fine, thanks :) |
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