Go icon indicating copy to clipboard operation
Go copied to clipboard

feat: Add Traveling Salesman Problem algorithm and tests

Open harshithsaiv opened this issue 1 year ago • 5 comments

Implemented Traveling Salesman Problem using Dynamic Programming

harshithsaiv avatar Apr 17 '24 22:04 harshithsaiv

@TruongNhanNguyen can you please review the code

harshithsaiv avatar Apr 18 '24 17:04 harshithsaiv

@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).

sozelfist avatar Apr 19 '24 00:04 sozelfist

Although your implementation is LGTM, some points in your code need to be changed or improved further.

  1. Variable Names: Variable names like n, dp, mask, i, and j are common in dynamic programming algorithms, but they could be more descriptive to enhance readability. For instance, n could be renamed to numCities, dp could be costTable, and so on.
  2. We can refactor the code to separate the logic into reusable functions:
    • initializeCostTable initializes the cost table with maximum costs.
    • updateCostTable updates the cost table with the minimum cost to reach each city.
    • findMinimumCost finds the minimum cost to complete the traveling salesman route.
    • The main logic for solving the traveling salesman problem is encapsulated within the TravelingSalesman function, which orchestrates the use of the helper functions.

sozelfist avatar Apr 19 '24 00:04 sozelfist

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.

codecov-commenter avatar Apr 24 '24 19:04 codecov-commenter

LGTM.

sozelfist avatar Apr 24 '24 23:04 sozelfist

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.

github-actions[bot] avatar Jun 13 '24 00:06 github-actions[bot]

This PR was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jul 26 '24 00:07 github-actions[bot]