filled in skeleton of negative cycle detection algorithm