docs: int checkNumberOfConnections( List<SquareNode> graph ) {
  		int histogram[] = new int[5];
  
  		for (int i = 0; i < graph.size(); i++) {
  			histogram[ graph.get(i).getNumberOfConnections() ]++;
  		}
  
  		if( graph.size() == 1 ) {
  			if( histogram[0] != 1 )
  				return 0;
  
  			return 1;
  		} else if( histogram[1] == 2 ) {
  			// line
  			if( histogram[0] != 0 )
  				return 0;
  			if( histogram[2] != graph.size()-2 )
  				return 0;
  			if( histogram[3] != 0 )
  				return 0;
  			if( histogram[4] != 0 )
  				return 0;
  
  			return 1;
  		} else {
  			// grid
  			if (histogram[0] != 0)
  				return 0;
  			if (histogram[1] != 0)
  				return 0;
  			if (histogram[2] != 4)
  				return 0;
  			return 2;
  		}
  	}