Skip to main content

GATE CSE 2020Algorithms › Graph AlgorithmsVerified

GATE CSE 2020 PYQ: Let G = ( V , E ) G = (V,E) G = ( V , E ) be a directed, weighted graph with weight function w : E → R w: E…

Let G=(V,E)G = (V,E) be a directed, weighted graph with weight function w:E→Rw: E \rightarrow \mathbb{R}. For some function f:V→Rf: V \rightarrow \mathbb{R}, for each edge(u,v)∈E(u,v)\in E, define w′(u,v){w}'(u,v) as w(u,v)+f(u)−f(v)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 GG under ww are shortest paths under w′{w}' too,_____________”.

  1. A
    for every f:V→Rf: V \rightarrow \mathbb{R}
    Correct answer
  2. B
    if and only if ∀u∈V, f(u)\forall u \in V, \: f(u) is positive
  3. C
    if and only if ∀u∈V, f(u)\forall u \in V, \: f(u) is negative
  4. D
    if and only if f(u)f(u) is the distance from ss to uu in the graph obtained by adding a new vertex ss to GG and edges of zero weight from ss to every vertex of GG

Answer

(A) for every f : V → R f: V \rightarrow \mathbb{R} f : V → R

Approach

Use the telescoping property of the reweighting function. For any path, the sum of the modified edge weights equals the original path weight plus a constant depending only on the first and last vertices. Hence every path between the same pair of vertices has its weight shifted by the same amount, so shortest paths are preserved for any vertex potential f.

The reweighting w'(u,v)=w(u,v)+f(u)-f(v) changes every path from s to t by the same additive constant f(s)-f(t). Therefore all path lengths shift equally, and shortest paths under w remain shortest under w' for every f: V -> R. Options B and C impose irrelevant sign conditions, while D gives only a sufficient condition, not a necessary one.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.