#### Question

Let G = (V, E) be a weighted, directed graph with weight function w: E → ℝ and no negative-weight cycles. Let s ∈ V be the source vertex, and let G be initialized by INITIALIZE-SINGLE-SOURCE (G, s). Prove that for every vertex

$v ∈ V_π$

, there exists a path from s to in

$G_π$

and that this property is maintained as an invariant over any sequence of relaxations.

#### Solution

Verified#### Step 1

1 of 2The only vertex in $\mathrm{V}_{\mathrm{\pi}}$ is $\mathrm{s}$, and there is trivially a path from s to itself. Now suppose that after any sequence of n relaxations, for every vertex $v \in V_{\pi}$ there exists a path from $s$ to $v$ in $G_{m}$. Consider the $(n+1)^{st}$ relaxation. Suppose it is such that $v \cdot d>u \cdot d+w(u, v) .$ When we relax $v,$ we update $v . \pi=u . \pi .$ By the induction hypothesis, there was a path from $\mathrm{s}$ to $\mathrm{u}$ in $\mathrm{G}_{\pi}$. Now $\mathrm{v}$ is in $\mathrm{V}_{\pi}$, and the path from $\mathrm{s}$ to $\mathrm{u},$ followed by the edge $(u, v)=(v \cdot \pi, v)$ is a path from $s$ to $v$ in $G_{\pi},$ so the claim holds.