Beispiel #1
0
        /// <summary>
        /// Load cities from the text file representing the adjacency matrix
        /// </summary>
        private void LoadCities(Cities cities)
        {
            double[][] arrayDistances = cities.GetArrayDistances();
            int        numCities      = cities.NumCities;

            distances = new double[numCities, numCities];
            for (int i = 0; i < numCities; i++)
            {
                for (int j = 0; j < numCities; j++)
                {
                    distances[i, j] = (double)arrayDistances[i][j];
                }

                //the number of rows in this matrix represent the number of cities
                //we are representing each city by an index from 0 to N - 1
                //where N is the total number of cities
                currentOrder.Add(i);
            }

            if (currentOrder.Count < 1)
            {
                throw new Exception("No cities to order.");
            }
        }