feat: Add Traveling Salesman Problem algorithm and tests
Implemented Traveling Salesman Problem using Dynamic Programming
@TruongNhanNguyen can you please review the code
@harshithsaiv Sure, I can provide suggestions that you would like to apply into your code to improve it. I'm just a contributor to this repo and only have contribute rights (give suggestions to make the PR to be better, not the right to merge code into master branch).
Although your implementation is LGTM, some points in your code need to be changed or improved further.
- Variable Names: Variable names like
n,dp,mask,i, andjare common in dynamic programming algorithms, but they could be more descriptive to enhance readability. For instance,ncould be renamed tonumCities,dpcould becostTable, and so on. - We can refactor the code to separate the logic into reusable functions:
initializeCostTableinitializes the cost table with maximum costs.updateCostTableupdates the cost table with the minimum cost to reach each city.findMinimumCostfinds the minimum cost to complete the traveling salesman route.- The main logic for solving the traveling salesman problem is encapsulated within the
TravelingSalesmanfunction, which orchestrates the use of the helper functions.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 87.43%. Comparing base (
833a3e5) to head (c2ff1c3).
Additional details and impacted files
@@ Coverage Diff @@
## master #717 +/- ##
==========================================
+ Coverage 87.36% 87.43% +0.07%
==========================================
Files 200 201 +1
Lines 5317 5350 +33
==========================================
+ Hits 4645 4678 +33
Misses 533 533
Partials 139 139
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
LGTM.
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 PR was closed because it has been stalled for 7 days with no activity.