Option A is correct.
There is a graph G, let us consider G is this.
Notice in the question there are two functions w, w’ which are assigning weights to the graph.The question already assumes that their shortest paths are same in both w, w’ now they want to find what can be possible.
Now if we add some positive number to all the edges to every edge of graph G given here then we may change the shortest path E.g. add 2 to all the edges in G
This is why option B can not be the answer.
The same thing will happen if we add some negative number to all the edges then also we will find that shortest paths is changing.
This is why option C can not be the answer.
So we get that we can not add some +ve number also we can not add some -ve number to the previous weights(assigned by w). [Basically , w(u,v) = w’(u,v)]
We have left with one thing only that f(u) - f(v) = 0;
So, f(v) = f(u), for all (u, v) $\epsilon$ E.
This can be satisfied in many ways, E.g. lets take f: V→ R and f(u) = some constant , $\forall$ u $\epsilon$ V.
So option A is correct
Now we will talk about option D, here we are adding a new vertex S to G,
Also f(u) = 0, u $\epsilon$ V because distance(S, u) = 0
Here also f(v) = f(u), for all (u, v) $\epsilon$ E, is satisfying but this is not the only way.
The condition given is sufficient but not necessary. So “if and only if“ is wrong.