private Map<Integer, List<Integer>> createDAG(String sentence) {
        Map<Integer, List<Integer>> dag = new HashMap<Integer, List<Integer>>();
        TrieNode trie = wordDict.getTrie();
        int N = sentence.length();
        int i = 0, j = 0;
        TrieNode p = trie;
        while (i < N) {
            char ch = sentence.charAt(j);
            if (p.childs.containsKey(ch)) {
                p = p.childs.get(ch);
                if (p.childs.containsKey(' ')) {
                    if (!dag.containsKey(i)) {
                        List<Integer> value = new ArrayList<Integer>();
                        dag.put(i, value);
                        value.add(j);
                    } else
                        dag.get(i).add(j);
                }
                j += 1;
                if (j >= N) {
                    i += 1;
                    j = i;
                    p = trie;
                }
            } else {
                p = trie;
                i += 1;
                j = i;
            }
        }
        for (i = 0; i < N; ++i) {
            if (!dag.containsKey(i)) {
                List<Integer> value = new ArrayList<Integer>();
                value.add(i);
                dag.put(i, value);
            }
        }
        return dag;
    }