* @param height          The height of the grid array
	 * @param d          The dimension of the initial drawing area
	 */
	protected void initGrid(int width, int height, Dimension d) {
		if ( (width > MAX_GRID_X) || (height > MAX_GRID_Y) ){
			throw new IllegalStateException ( ); // hack bf
			//return;
		}
		int i, j;

		if (algo == Algo.SOM)
			maxNodes = width * height;

		//
		// add nodes
		//
		for (i = 0; i < width; i++)
			for (j = 0; j < height; j++)
			{
				addGridNode(i, j, d);
//				if (i+j<=2) {
//					NodeGNG n = grid[i][j].node;
//					System.out.printf("initGrid(): new node: %d %d x_grid= %d y_grid = %d  x=%5.3f y=%5.3f\n", i,j,n.x_grid,n.y_grid,n.x,n.y);
//				}
			}

		gridWidth = width;
		gridHeight = height;

		//
		// add edges
		//
		for (i = 0; i < gridWidth; i++) {
			for (j = 0; j < gridHeight; j++) {
				if ( i < (gridWidth - 1) )
					addEdge(grid[i][j].index, grid[i+1][j].index);
				if ( j < (gridHeight - 1) )
					addEdge(grid[i][j].index, grid[i][j+1].index);
			}
		}
	}