private void dfs(String source, String target,
                     Map<String, Set<String>> map,
                     Map<String, Integer> d,
                     List<List<String>> lists,
                     LinkedList<String> path) {
        if (target.equals(source)) {
            path.addFirst(target);
            lists.add(new ArrayList<>(path));
            path.removeFirst();
            return;
        }
        path.addFirst(source);
        for (String s : map.get(source)) {
            if (d.getOrDefault(s, -10) + 1 == d.get(source)) {
                dfs(s, target, map, d, lists, path);
            }
        }
        path.removeFirst();
    }
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