code: public static double calcAverageDegree(HashMap<Character, String[]> keys)
      {
          double average = 0d;
          for (Map.Entry<Character, String[]> entry : keys.entrySet())
          {
              average += neighborsNumber(entry.getValue());
          }
          return average / (double) keys.size();
      }
docs: Calculates the average "degree" of a keyboard or keypad. On the qwerty
  keyboard, 'g' has degree 6, being adjacent to 'ftyhbv' and '\' has degree
  1.
  
  @param keys a keyboard or keypad
  @return the average degree for this keyboard or keypad