Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Negative Cycle in Directed weigthed graph

Revision en4, by Peace_789, 2020-06-11 21:41:24

Hello Everyone ...

Today I was solving this problem ... Problem statement : You are given a directed weighted graph, and your task is to find out if it contains a negative cycle, and also give an example of such a cycle.

I am aware of solving this problem using Bellman Ford's Algorithm , But I am trying another approach which is giving me WA in 1 Test Case (total 13 is there) .

So , Can anyone point out whether this approach is correct or not ... and If it is correct then suggest me some modification otherwise give some counter examples where this code might fail.

code

Thanks in advance :) and sorry for my bad english.

Tags #graph theory, #cycle, #doubt

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Peace_789 2020-06-11 21:41:24 944 Tiny change: '="code">\n...\n\n~~~~~\nYour code here...\n#include' -> '="code">\n~~~~~\n#include'
en3 English Peace_789 2020-06-11 15:26:27 18 Tiny change: ' directed graph,' -> ' directed weighted graph,'
en2 English Peace_789 2020-06-11 15:16:48 503
en1 English Peace_789 2020-06-11 15:08:27 2980 Initial revision (published)