Skip to content

Instantly share code, notes, and snippets.

@Squirrelbd
Created December 11, 2022 10:32
Show Gist options
  • Save Squirrelbd/501ad78b1a7d3eb544e0d5fc49f8e6bb to your computer and use it in GitHub Desktop.
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
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;
}
}
@Squirrelbd
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment