public AcyclicLP(EdgeWeightedDigraph G, int s) {
   this.s = s;
   distTo = new double[G.V()];
   for (int i = 0; i < distTo.length; i++) {
     distTo[i] = INFINITY;
   }
   edgeTo = new DirectedEdge[G.V()];
   EdgeWeightedTopologicalOrder order = new EdgeWeightedTopologicalOrder(G);
   int count = 0;
   int kb = Integer.MAX_VALUE;
   edgeTo[s] = null;
   distTo[s] = 0; /* initialize*/
   for (int i : order.reversePost()) {
     if (i == s) {
       kb = count;
     }
     if (count < kb) {
       count++;
       continue;
     }
     relax(G, i);
   }
 }