TravellingSalesman

TravellingSalesman - /* / TravellingSalesman.java / /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // TravellingSalesman.java // // Demonstration of the travelling salesman problem. For a given list // of cities with coordinates, all possible routes from the first // city to the last city are displayed along with the total length of // each route. //******************************************************************** / import java.io.IOException; import java.util.Scanner; import java.util.ArrayList; import java.util.regex.Pattern; import java.util.regex.MatchResult; import java.util.InputMismatchException; i public class TravellingSalesman { //---------------------------------------------------------------- // Number of routes we have computed //---------------------------------------------------------------- int routes = 0; //---------------------------------------------------------------- // Simple record class representing a City //---------------------------------------------------------------- public static class City { double x = 0; double y = 0; String name = null; S public City(String name, double x, double y) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

TravellingSalesman - /* / TravellingSalesman.java / /...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online