static void Main(string[] args) { //create an initial tour out of nearest neighbors var stops = Enumerable.Range(1, 10) .Select(i => new Stop(new City(i))) .NearestNeighbors() .ToList(); //create next pointers between them stops.Connect(true); //wrap in a tour object Tour startingTour = new Tour(stops); //the actual algorithm while (true) { Console.WriteLine(startingTour); var newTour = startingTour.GenerateMutations() .MinBy(tour => tour.Cost()); if (newTour.Cost() < startingTour.Cost()) { startingTour = newTour; } else { break; } } Console.ReadLine(); }