private int BFS(Graph graph, String start, String end) {
        int length = 1;
        if (start.equals(end))
            return 0;

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

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

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

        return reaching.size() > 0 ? length : 0;
    }