About cyclic graph

how to check whether a graph is cyclic? is it necessary for a graph to be cyclic before checking whether it contains a negative weight cycle or not?

Hey @Senjuti256
After relaxing edges for V-1 times
If u get further reduction in next relaxation i.e Vth then that means graph contains negative cycle

You dont have to worry abt positive cycle

No no, I understood that. I am asking how to check whether a graph is cyclic or not? Is it necessary that graph has to be cyclic to contain a – weight cycle?

You can apply dfs with some modification to check graph is cyclic or not but that is not required here.

Yes its ,if graph contains a -ve weight cycle then it has to be cyclic :stuck_out_tongue:

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.