After running Floyd-Warshall, check the diagonal: if dist[i][i] < 0 for any , there is a negative cycle. Why?
A negative diagonal means you can start at , follow some cycle, and return to with negative total weight. If any dist[i][i] < 0, the graph contains a negative cycle and shortest paths are undefined. You can report this condition and stop. This check takes time after the main algorithm.
Space complexity is for the distance matrix.