Add Dijkstra Algorithm Implementation Using PriorityQueue (Fixes #7112)
Summary
This Pull Request adds a clean and efficient implementation of Dijkstra’s Algorithm using a PriorityQueue, as requested in issue #7112.
What This PR Includes
- New file
Dijkstra.javainside the appropriate package. - Implementation of Dijkstra’s shortest-path algorithm using:
- Adjacency list representation
- Min-heap (PriorityQueue)
- Detection and handling of negative weighted edges (throws exception, as required).
- Code follows the structure, style, and formatting used throughout the TheAlgorithms/Java repository.
Why This Change Is Needed
The project did not previously include a fully correct and optimized Dijkstra implementation using a PriorityQueue.
This PR fills that gap and matches the algorithm request posted under issue #7112.
Related Issue
Fixes #7112
Codecov Report
:x: Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 78.55%. Comparing base (e6c576c) to head (02f4f23).
:warning: Report is 4 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...com/thealgorithms/greedyalgorithms/KruskalMST.java | 95.45% | 1 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #7123 +/- ##
============================================
+ Coverage 78.46% 78.55% +0.08%
- Complexity 6746 6748 +2
============================================
Files 758 760 +2
Lines 22339 22431 +92
Branches 4384 4405 +21
============================================
+ Hits 17528 17620 +92
+ Misses 4107 4102 -5
- Partials 704 709 +5
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.