GATE 2020 CS – Question 50
Let $G=(V,E)$ be a directed, weighted graph with weight function $w:E\to\mathbb{R}$. For some function $f:V\to\mathbb{R}$, for each edge $(u,v)\in E$, define $w'(u,v)$ as $w(u,v)+f(u)-f(v)$.
Which one of the options completes the following sentence so that it is TRUE? "The shortest paths in $G$ under $w$ are shortest paths under $w'$ too, ______."
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) for every $f:V\to\mathbb{R}$
Explanation
For any path from $s$ to $t$ the reweighted length is $w(p)+f(s)-f(t)$. The extra term depends only on the endpoints, so the ordering of paths between the same endpoints is unchanged for every $f$ (this is Johnson's reweighting).