public Neuron getWinningNeuron(double[] pattern)
    {
	//The neuron that will fire open reading the input pattern.
	Neuron winner = null;

	//Stores the distance between the input pattern,
	//and the closest neuron to the pattern in the 2D output 
	//space. Initially set it to farthest possible distance away.
	double closest = Double.MAX_VALUE;

	//For each neuron in the 2D output space.
	for (int i = 0; i < mapWidth; i++)
	{
	    for (int j = 0; j < mapWidth; j++)
	    {
		//Find the distance between the input pattern
		//and the weights of connections for the neuron at position [i,j] 

		double distance = CalcEuclideanDistance(pattern, outputNeurons[i][j].weights);

		//if the distance is less than the current closest output neuron,
		//then we change the distance to the newer smaller value,
		//and select the neuron at this closer distances as the winning
		//output neuron.
		if (distance < closest)
		{
		    winner = outputNeurons[i][j];
		    closest = distance;
		}
	    }
	}

	//return the winning neuron.
	return winner;
    }