detect negative cycle