Can Someone help me in checking the negative Cycle?

Can Someone give me a hint of code on how to implement it.

hello @JaveedYara

first run ur floyd warshall algorithm

once done with all iterations then check whether distance of node with itself is negative or not. if it is then cycle is present otherwise not.

a) floyd warshal
b) iterate all node v .
           if distance[v][v] < 0 
                  cycle present    
1 Like