Created
December 11, 2022 10:32
-
-
Save Squirrelbd/501ad78b1a7d3eb544e0d5fc49f8e6bb to your computer and use it in GitHub Desktop.
Traveling Salesman Problem Using Dynamic Programming in Java [Flight Planning] [Solved]. Complete project at: https://www.programmingboss.com/2022/12/traveling-Salesman-Problem-Using-Dynamic-Programming-Java-Flight-Planning.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
// Class | |
class City implements Comparator<City> | |
{ | |
public String city; | |
public int cost; | |
public City() | |
{ | |
} | |
// Compare the nodes. | |
@Override | |
public int compare(City node1, City node2) | |
{ | |
if (node1.cost < node2.cost) | |
return -1;if (node1.cost > node2.cost) | |
return 1; | |
return 0; | |
} | |
public City(String city, int cost) | |
{ | |
this.city = city; | |
this.cost = cost; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traveling Salesman Problem Using Dynamic Programming in Java [Flight Planning] [Solved]. Complete the project at: https://www.programmingboss.com/2022/12/traveling-Salesman-Problem-Using-Dynamic-Programming-Java-Flight-Planning.html