About negative cycle in Floyd algo

can the Floyd warshall algorithm work on a graph with negative cycle?

Hey @Senjuti256 floyd also doesn’t work on negative cycle. Only bellman algo works on negative cycle :slight_smile:

Bellman Ford works on graph with negative edges that is ok. But how does it work on graphs having negative edge cycle? There we display that graph contains negative cycle so least distance can’t be found out.

You are asking this for bellman ford?

U mentioned that bellman only works on negative cycle so I asked how does it work on such graphs?

I meant to say negative edge, it was my mistake. If you will have negative cycle, then you will never reach to your destination. You will move on that cycle only.

Yea yea thanks. Can Floyd work on graphs with negative edges?

Yes Floyd warshall algo works on negative edges.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.