public Route GreedyRouteConstruction() { double distance = 0; double profit = 0; List <Node> route = new List <Node>(); //construct route List <Node> unvisited = new List <Node>(NodesList); Node currentNode; Node startNode = new Node(); //int random = rand.Next(0, NodesList.Count - 1); //random = rand.Next(0, NodesList.Count - 1); startNode = NodesList.ElementAt(0); route.Add(startNode); //add start point to route unvisited.Remove(startNode); currentNode = startNode; while (distance < Dmax) { Node best = GetTheBestNode(currentNode, unvisited, distance, profit); //get whivh has the best overal profil to distance if (CheckDistance(distance, Dmax, currentNode, best, startNode)) //check wether route back to start is possible { distance = distance + NodeDistances[currentNode.Position, best.Position]; profit = profit + best.Profit; route.Add(best); unvisited.Remove(best); currentNode = best; } else { break; } } route.Add(route.ElementAt(0)); distance = distance + NodeDistances[route.ElementAt(route.Count() - 2).Position, route.ElementAt(route.Count() - 1).Position]; //UnvisitedNodesList = unvisited; Route r = new Route(); r.CalculatedRoute = route; r.Distance = distance; r.RouteProfit = profit; r.Unvisited = unvisited; UnvisitedNodesList = unvisited; return(r); }