-
Notifications
You must be signed in to change notification settings - Fork 275
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
Implemented A* algorithm and updated test cases #576
Conversation
@Kishan-Ved @czgdp1807 |
pydatastructs/graphs/algorithms.py
Outdated
if algorithm == 'a_star_with_manhattan': | ||
# A* with this implementation requires both source and target | ||
if not target: | ||
raise ValueError("Target must be specified for A* algorithm") | ||
|
||
func = "_a_star_with_manhattan_" + graph._impl | ||
return getattr(algorithms, func)(graph, source, target) |
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.
This is not needed. The logic below already handles this.
@@ -293,7 +292,34 @@ def _test_shortest_paths_positive_edges(ds, algorithm): | |||
graph.remove_edge('SLC', 'D') | |||
graph.add_edge('D', 'SLC', -10) | |||
assert raises(ValueError, lambda: shortest_paths(graph, 'bellman_ford', 'SLC')) | |||
|
|||
def _test_a_star_manhattan(ds): |
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.
def _test_a_star_manhattan(ds): | |
def _test_a_star_manhattan(ds): |
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.
should i remove this tests for the astar algorithem here?
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.
This suggestion means that you need to add a blank line before the function definition starts.
It's a path setting issue in VSCode. You need to add PATH to your conda environment headers in VSCode settings. |
@czgdp1807 I have implemented the requested changes. However, the failing GitHub CI/CD tests appear to be due to a different import error related to the C++ node modules. Could you please verify if this issue is caused by my changes? |
Are the tests working on your local machine? Check the README to know how to run the tests. |
Inorder to debug, do this:
|
@Kishan-Ved @czgdp1807 1.one thing is that i can re-fork my local repo and give a new PR ? please let me if any other method are there to resolve this ASAP.. |
pydatastructs/graphs/algorithms.py
Outdated
@@ -24,6 +25,7 @@ | |||
'topological_sort', | |||
'topological_sort_parallel', | |||
'max_flow' |
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.
'max_flow' | |
'max_flow', |
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 add a comma here.
pydatastructs/graphs/algorithms.py
Outdated
@@ -11,6 +11,7 @@ | |||
from pydatastructs.graphs.graph import Graph | |||
from pydatastructs.linear_data_structures.algorithms import merge_sort_parallel | |||
from pydatastructs import PriorityQueue | |||
from pydatastructs.graphs.graph import AdjacencyListGraphNode |
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.
from pydatastructs.graphs.graph import AdjacencyListGraphNode |
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.
I see that you have added this import, but it is being used in a code block that is commented. Please try removing this and check if the CI tests pass.
pydatastructs/graphs/algorithms.py
Outdated
@@ -11,6 +11,7 @@ | |||
from pydatastructs.graphs.graph import Graph | |||
from pydatastructs.linear_data_structures.algorithms import merge_sort_parallel | |||
from pydatastructs import PriorityQueue | |||
from pydatastructs.graphs.graph import AdjacencyListGraphNode |
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.
I see that you have added this import, but it is being used in a code block that is commented. Please try removing this and check if the CI tests pass.
@Kishan-Ved |
@@ -811,6 +818,55 @@ def _dijkstra_adjacency_list(graph: Graph, start: str, target: str): | |||
|
|||
_dijkstra_adjacency_matrix = _dijkstra_adjacency_list | |||
|
|||
def _a_star_with_manhattan_adjacency_list(graph: Graph, start: str, target: str, **kwargs): |
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.
Try changing the body of this function to pass
. Check if the CI checks pass. Else, make a new PR with small code additions and one commit at a time, and ensure CI passes.
References to other Issues or PRs or Relevant literature
fixes #486
https://github.com/codezonediitj/pydatastructs/pull/283/files
https://github.com/codezonediitj/pydatastructs/pull/301/files
Brief description of what is fixed or changed
1.implemented a star algorithm with the help of Manhattan heustric and took reference from the Wikipedia
2.took reference from the Dijkstra and bellman ford algorithm for test cases and code writing
Other comments