import java.util.ArrayList;


public class greedyTSP 
{
	SriramCity city = new SriramCity();
	ArrayList<Integer> tour = new ArrayList<Integer>();
	int bestCity = 0;
	int bestPosition = 0;
	int smallestIncrease = 0;
	boolean[] visited;
	public greedyTSP()
	{
		visited = new boolean[128];
		for (int i = 0; i < 128; i++)
			visited[i] = false;
		tour.add(city.getIndex(city.cityName[0], city.cityState[0]));
		visited[0] = true;
		tour.add(city.getIndex(city.cityName[1], city.cityState[1]));
		visited[1] = true;
		tour.add(city.getIndex(city.cityName[2], city.cityState[2]));
		visited[2] = true;

		do 125 times
		{

		for (int i = 0; i < 128; i++)
			{
				if(visited[i] == false)
					{
					int currentDis = 0;
					int prevDis = 0;
					int bestDistance = 0;
					int index = 0;
					int bestCity = 0;
					for (int j = 1; j < tour.length; j ++)
						{
							prevDis = currentDis;
							tour.add(j+1, city.getIndex(city.cityName[i], city.cityState[i]));
							currentDis = tourDistance(tour);
							if (currentDis < prevDis)
								{
									bestDistance = currentDis;
									index = j;
									bestCity = city.getIndex(city.cityName[i], city.cityState[i]);
								}
								
						}
					}
			}
			
			// A best city and a best position have been identified. This needs to be added to tour

		} // do 125 times


	}

	
	public int tourDistance(ArrayList<Integer> tour)
	{
		int tourDistance = 0;
		for (int i = 0; i < (tour.size()-1); i++)
			tourDistance += getDistance(tour.get(i), tour.get(i+1));
		return tourDistance;
			
	}
	public int getDistance(int i, int j)
	{
		int distance = 0;
		
		if (i < j)
			{
				distance = city.distances[j][i];
			}
		else
		{
			distance = city.distances[i][j];
		}
		return distance;
	}
	public static void main(String args[])
	{
		greedyTSP g = new greedyTSP();
		System.out.println(g.tour);
		
	}
}
