Skip to content

Conversation

@prasanth-30011
Copy link

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.java inside 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-commenter
Copy link

Codecov Report

❌ Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.55%. Comparing base (e6c576c) to head (02f4f23).
⚠️ 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 ⚠️
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     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

FEATURE REQUEST] Dijkstra's Algorithm with Priority Queue

2 participants