code: public static int getShifts(final AdjacencyGraph adjacencyGraph, final String part)
      {
          int current_shift = -1;
          int shifts = 0;
          char[] parts = part.toCharArray();
  
          for (int i1 = 0; i1 < parts.length; i1++)
          {
              Character character = parts[i1];
              if (i1 + 1 >= parts.length)
              {
                  continue;
              }
  
              Character next_character = parts[i1 + 1];
  
              if (adjacencyGraph.getKeyMap().containsKey(character))
              {
                  String[] tmp_neighbors = adjacencyGraph.getKeyMap().get(character);
                  for (final String tmp_neighbor : tmp_neighbors)
                  {
                      if (tmp_neighbor == null)
                      {
                          continue;
                      }
                      int i = 0;
                      for (Character neighbor_char : tmp_neighbor.toCharArray())
                      {
                          if (next_character.equals(neighbor_char))
                          {
                              if (current_shift == -1)
                              {
                                  current_shift = i;
                              }
                              else if (current_shift != i)
                              {
                                  shifts++;
                                  current_shift = i;
                              }
                          }
                          i++;
                      }
                  }
              }
          }
          return shifts;
      }
docs: Returns the number of shifts in case in the part passed in.
  
  @param adjacencyGraph the graph you are using to get the neighbors
  @param part           the string you are getting shifts for.
  @return the number of shifts in this string for the {@code AdjacencyGraph}