-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: improve Dijkstra algorithm with proper min-heap implementation #781
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
fix: improve Dijkstra algorithm with proper min-heap implementation #781
Conversation
- Replace MaxHeap confusion with dedicated min-heap using container/heap
- Add comprehensive input validation and error handling
- Improve type safety by removing interface{} usage
- Add early termination optimization for better performance
- Maintain backward compatibility with existing API
- Add DijkstraWithPath() and DijkstraAllPairs() functionality
- Include comprehensive test suite with edge cases and benchmarks
fix: typo in .github/ISSUE_TEMPLATE/bug_report.yml
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This comment should remove stale label
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This comment should remove stale label
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Uh oh!
There was an error while loading. Please reload this page.
Description of Change
This PR significantly improves the Dijkstra algorithm implementation in
graph/dijkstra.goby addressing several critical issues found in the current implementation:Problems Fixed:
interface{}usage and unsafe castsImprovements Made:
container/heapNew Features Added:
DijkstraWithPath()- Returns complete shortest path reconstructionDijkstraAllPairs()- Computes distances to all reachable nodesPerformance & Quality:
Checklist
Notes: This improvement maintains 100% backward compatibility while fixing critical algorithmic and type safety issues. All existing code using
Dijkstra()will continue to work unchanged, but with better performance and reliability.