Digraph without circuits with negative cost Let $D=(V,E)$ be a digraph and let $a\colon E\to\mathbb{R}$ be a cost function on the edges.

How can I prove that $D$ has no circuits with negative costs only if there exists a function $\pi\colon V\to\mathbb{R}$ such that $a(uv) + \pi(u) − \pi(v) \ge 0$, for all $uv\in E$?

I realised that this is true by some examples, but I can't realise how can I prove that this is true in general?
Sum up the value of $a(uv)+\pi(u)-\pi(v)$ over all the edges in some circuit.  What can you say about the result?  What does this imply about whether that circuit was a negative circuit?