private HashMap<String, HashSet<String>> BFS() {
        HashMap<String, HashSet<String>> reverseLinks = new HashMap<String, HashSet<String>>();
        if (startWord.equals(endWord))
            return reverseLinks;

        HashSet<String> visited = new HashSet<String>();
        HashSet<String> outGoing = new HashSet<String>();
        HashSet<String> reaching = new HashSet<String>();
        reaching.add(startWord);
        visited.add(startWord);

        while (!visited.contains(endWord) && reaching.size() > 0) {
            HashSet<String> temp = outGoing;
            outGoing = reaching;
            reaching = temp;
            reaching.clear();

            for (String fromWord : outGoing) {
                for (String toWord : graph.connectTo(fromWord)) {
                    if (!visited.contains(toWord)) {
                        reaching.add(toWord);

                        HashSet<String> from = reverseLinks.get(toWord);
                        if (from == null) {
                            from = new HashSet<String>();
                            reverseLinks.put(toWord, from);
                        }
                        from.add(fromWord);
                    }
                }
            }

            visited.addAll(reaching);
        }

        return reverseLinks;
    }