Skip to content

Create graphs/dijkstra_alternate.py #7405

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

Merged
merged 17 commits into from
Oct 20, 2022
Merged

Conversation

AtulRajput01
Copy link
Contributor

@AtulRajput01 AtulRajput01 commented Oct 18, 2022

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Copy link
Contributor Author

@AtulRajput01 AtulRajput01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all set , all functions work well

@ZeroDayOwl
Copy link
Contributor

@AtulRajput01 check pre-commit details and fix the issues.

@cclauss
Copy link
Member

cclauss commented Oct 19, 2022

Instead of deleting someone else's work, let's move this to a separate file graphs/dijkstra_alternate.py and make sure that naming, tests, type hints are in compliance with https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md

@AtulRajput01
Copy link
Contributor Author

Instead of deleting someone else's work, let's move this to a separate file graphs/dijkstra_alternate.py and make sure that naming, tests, type hints are in compliance with https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md

okay

Copy link
Contributor Author

@AtulRajput01 AtulRajput01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@AtulRajput01
Copy link
Contributor Author

@AtulRajput01 check pre-commit details and fix the issues.

code fix .

@cclauss
Copy link
Member

cclauss commented Oct 19, 2022

graphs/dijkstra.py:6:10: N802 function name 'printSolution' should be lowercase
graphs/dijkstra.py:11:10: N802 function name 'minDistance' should be lowercase
graphs/dijkstra.py:11:34: N803 argument name 'sptSet' should be lowercase
graphs/dijkstra.py:13:9: A001 variable "min" is shadowing a python builtin
graphs/dijkstra.py:16:44: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
graphs/dijkstra.py:17:17: A001 variable "min" is shadowing a python builtin
graphs/dijkstra.py:26:10: N806 variable 'sptSet' in function should be lowercase
graphs/dijkstra.py:28:13: B007 Loop control variable 'cout' not used within the loop body. If this is intended, start the name with an underscore.
graphs/dijkstra.py:36:35: E712 comparison to False should be 'if cond is False:' or 'if not cond:'

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 19, 2022
@AtulRajput01
Copy link
Contributor Author

AtulRajput01 commented Oct 19, 2022

done sir

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to CONTRBUTING.md there needs to be at least one algorithmic function that takes in one or more parameters and returns one or more values. Algorithmic functions should not print().

@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 19, 2022
Co-authored-by: Christian Clauss <cclauss@me.com>
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 19, 2022
AtulRajput01 and others added 2 commits October 20, 2022 00:08
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 19, 2022
@AtulRajput01
Copy link
Contributor Author

According to CONTRBUTING.md there needs to be at least one algorithmic function that takes in one or more parameters and returns one or more values. Algorithmic functions should not print().

okay sir ,i understood very well.

Copy link
Contributor

@Abinashbunty Abinashbunty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • In line 30, during function call, it should be self.minimum_distance
  • All dist should be distances or vice versa.
  • All sptset should be spt_set or vice versa or a more self-documenting name.
  • printsolution should be print_solution or vice versa.
  • Include doctests.
  • Provide some comments in algorithm execution.

@Abinashbunty
Copy link
Contributor

A general advice is to execute the code online/locally to fix the compilation(interpreter) errors. 👍🏻

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 19, 2022
@AtulRajput01
Copy link
Contributor Author

AtulRajput01 commented Oct 19, 2022

A general advice is to execute the code online/locally to fix the compilation(interpreter) errors. 👍🏻

it's working on my machine as well, then why pre-commit failure accur

@cclauss
Copy link
Member

cclauss commented Oct 19, 2022

graphs/dijkstra.py:22:48: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
graphs/dijkstra.py:37:13: B007 Loop control variable 'cout' not used within the loop body. If this is intended, start the name with an underscore.
graphs/dijkstra.py:55:35: E712 comparison to False should be 'if cond is False:' or 'if not cond:'

Copy link
Contributor Author

@AtulRajput01 AtulRajput01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@Abinashbunty Abinashbunty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, check my comment above which Christian has edited. Use distances, spt_set and print_solution.

@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 19, 2022
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 19, 2022
@cclauss
Copy link
Member

cclauss commented Oct 19, 2022

OK. I changed the filename, used self-documenting names for functions and variables, added type hints, and docstrings with doctests.

I still have no clue what a better name for sptset would be except perhaps visited.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 19, 2022
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 19, 2022
@Abinashbunty
Copy link
Contributor

@cclauss visited seems the only logical variable name for sptset.

@cclauss cclauss changed the title Update dijkstra.py Create graphs/dijkstra_alternate.py Oct 19, 2022
@AtulRajput01 AtulRajput01 changed the title Create graphs/dijkstra_alternate.py Create graphs/dijkstra_alternate.py Oct 20, 2022
@ZeroDayOwl
Copy link
Contributor

A general advice is to execute the code online/locally to fix the compilation(interpreter) errors. 👍🏻

it's working on my machine as well, then why pre-commit failure accur

Did you run the tests as mentioned in the contributing guideline?

@AtulRajput01
Copy link
Contributor Author

AtulRajput01 commented Oct 20, 2022 via email

@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting reviews This PR is ready to be reviewed labels Oct 20, 2022
@cclauss cclauss merged commit 4829fea into TheAlgorithms:master Oct 20, 2022
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants