private HashMap<Integer, List<Integer>> searchNeighbors(String[] nodes) {
            HashMap<String, Integer> indices = new HashMap<String, Integer>(
                    nodes.length);
            int i = 0;
            for (String word : nodes) {
                indices.put(word, i++);
            }

            HashMap<Integer, List<Integer>> neighbors = new HashMap<Integer, List<Integer>>();

            i = 0;
            for (String word : nodes) {
                List<Integer> neighbor = neighbors.get(word);
                if (neighbor == null) {
                    neighbor = new ArrayList<Integer>();
                    neighbors.put(i, neighbor);
                }
                char[] temp = word.toCharArray();
                for (int j = 0; j < temp.length; j++) {
                    char oldC = temp[j];
                    for (char c = 'a'; c <= 'z'; c++) {
                        if (c != oldC) {
                            temp[j] = c;
                            String newS = new String(temp);
                            Integer index = indices.get(newS);
                            if (index != null) {
                                neighbor.add(index);
                            }
                        }
                    }
                    temp[j] = oldC;
                }
                i++;
            }
            return neighbors;
        }