protected static Digraph sn2topo(Digraph g){
        Digraph _g = new Digraph(g.V());    // the returning graph
        int[] mapping = new int[g.V()];     // index[old] = new
        
        Topological topo = new Topological(g);
        int i = 0;
        for(int v : topo.order()){
            mapping[v] = i;
            i++;
//            StdOut.print(v + " ");
        }
//        StdOut.println();
        
        for(int v = 0; v < g.V(); v++){
            for(int w : g.adj(v)){
                _g.addEdge(mapping[v], mapping[w]);
            }
        }
        
//        StdOut.println();
        return _g;
    }