Suppose There is a cycle of 'E' edges which follows above condition that means,
where Pi represents Profit of edge and Li represent loss of each edge.
(P1 + P2 +P3 +... PE)/(L1 + L2 + L3 +... LE) > R
=> (P1 + P2 + P3 + ... PE) > R(L1 + L2 + L3 + ... LE)
=> P1 - RL1 + P2 - RL2 + P3 - RL3 + ... + PE - RLE > 0
=> 1<= i <= E ∑ Pi - RLi > 0
So that it Means, We need to find a positive weighted cycle where each edge of the Cycle will represent Pi - RLi . It is the exact oppsite of Bellman ford
algorithm . That's Why we will take values of Pi as negative value and Li as positive value . Basically we will mark each edge as
-Pi+RLi
and then Find negative cycle via Bellman ford algoithm .