Conversation
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/graham_scan.py, please provide doctest for the function angle_comparer
Please provide descriptive name for the parameter: p
There was a problem hiding this comment.
To reviewers:
This is an inner function.
argument name is fixed here fdaacde
| angle = degrees(atan2(y - miny, x - minx)) | ||
| return angle | ||
|
|
||
| sorted_points = sorted(points, key=lambda p: angle_comparer(p)) |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: p
There was a problem hiding this comment.
argument name is fixed here fdaacde
| straight = 2 | ||
| right = 3 | ||
|
|
||
| def check_direction( |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/graham_scan.py, please provide doctest for the function check_direction
There was a problem hiding this comment.
To reviewers:
This is an inner function
ghost
left a comment
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| # remove the lowest and the most left point from points for preparing for sort | ||
| points.pop(minidx) | ||
|
|
||
| def angle_comparer(point: list[int, int]) -> float: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/graham_scan.py, please provide doctest for the function angle_comparer
| straight = 2 | ||
| right = 3 | ||
|
|
||
| def check_direction( |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file other/graham_scan.py, please provide doctest for the function check_direction
|
To reviewers: The test is failed at pre-commit because CI executes I did |
|
Doesn't this algorithm belong in https://github.com/TheAlgorithms/Python/tree/master/sorts ? or graphs? How does this algorithm compare with |
|
@cclauss |
|
Putting algorithms in |
|
I see.
divide_and_conquer algorithm is also known well to solve convex hull problem only by O(n * logn) time complexity. However, it's approach is totally different from graham scan. Graham scan doesn't use divide_and_conquer approach, but it focuses on sorting points by angle. |
|
Oh. Thank you for merging. I wonder if I should create other PR to move this to |
* Add graham scan algorithm
* Fix argument name p with point
* Add tests in inner function
* updating DIRECTORY.md
* Fix graham scan for isort --profile=black
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add graham scan algorithm
* Fix argument name p with point
* Add tests in inner function
* updating DIRECTORY.md
* Fix graham scan for isort --profile=black
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add graham scan algorithm
* Fix argument name p with point
* Add tests in inner function
* updating DIRECTORY.md
* Fix graham scan for isort --profile=black
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>

Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.