315316317318319320321322323324325
{// Target if ( cost[i][k] + cost[k][j] < cost[i][j] ) { if ( i == j ) { throw new NegativeCycleException(); } // It is cheaper to go through K. cost[i][j] = cost[i][k] + cost[k][j]; pred[i][j] = k;