Skip to content

Fix Dijkstra algorithm implementation #499

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 1 commit into from
Nov 27, 2024
Merged

Conversation

wm55414
Copy link
Contributor

@wm55414 wm55414 commented Nov 27, 2024

SUMMARY

  • The original implementation of Dijkstra algorithm can't go through vertices which have been counted previously. Add priority queue to fix it and modify the algorithm's test as well.

MOTIVATION

CONTENT

  1. Add priority queue to track the previous counted vertices distances. Then we can find the minimal distance across all the possible vertices.
  2. Remove redundant calculations.
  3. Modify the test cases.
  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

The original implementation of Dijkstra algorithm can't go through vertices which was counted previously. Add priority queue to fix it and modify the algorithm's test as well.
@wm55414 wm55414 requested a review from siriak as a code owner November 27, 2024 15:25
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.12%. Comparing base (0184c37) to head (517e1cc).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #499      +/-   ##
==========================================
- Coverage   95.16%   95.12%   -0.05%     
==========================================
  Files         267      267              
  Lines       10860    10848      -12     
  Branches     1528     1527       -1     
==========================================
- Hits        10335    10319      -16     
- Misses        400      403       +3     
- Partials      125      126       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak merged commit 0ef9849 into TheAlgorithms:master Nov 27, 2024
3 of 4 checks passed
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.

2 participants