private void addVertexAndEdge(String s, Map<String, Set<String>> map) {
        map.put(s, new HashSet<>());
        for (String key : map.keySet()) {
            if (canBeConnected(key, s)) {
                map.get(key).add(s);
                map.get(s).add(key);
            }
        }

    }
to all shortest paths, i first used bfs to find distance from source to target and, from target to source i did dfs
src/problems/hard/WordLadder2.java